Skip to content

🌱Add test for baremetalhost controller updateEventHandler#1881

Merged
metal3-io-bot merged 1 commit intometal3-io:mainfrom
troy0820:troy0820/saveHostStatus-predicate
Sep 27, 2024
Merged

🌱Add test for baremetalhost controller updateEventHandler#1881
metal3-io-bot merged 1 commit intometal3-io:mainfrom
troy0820:troy0820/saveHostStatus-predicate

Conversation

@troy0820
Copy link
Copy Markdown
Contributor

@troy0820 troy0820 commented Aug 13, 2024

What this PR does / why we need it:

When using this method, the saveHostStatus will requeue the object and create more reconciles for the object when the only thing that has changed is the lastupdated field in the status. This leads to multiple reconciles because this happens during each run through the reconciler.

This adds a test to the baremetalhost controller to validate that the saveHostStatus will not requeue the object and create more reconciles when lastUpdated is updated.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1253

@metal3-io-bot metal3-io-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 13, 2024
@metal3-io-bot
Copy link
Copy Markdown
Contributor

Hi @troy0820. Thanks for your PR.

I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@metal3-io-bot metal3-io-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 13, 2024
@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 8ae68ff to 1e33d18 Compare August 13, 2024 18:07
@metal3-io-bot metal3-io-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 13, 2024
Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 7fe7bfe to 1e5696c Compare August 13, 2024 19:09
@tuminoid
Copy link
Copy Markdown
Member

/ok-to-test

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 14, 2024
@troy0820
Copy link
Copy Markdown
Contributor Author

/test metal3-bmo-e2e-test

@metal3-io-bot
Copy link
Copy Markdown
Contributor

@troy0820: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test generate
  • /test gomod
  • /test manifestlint
  • /test markdownlint
  • /test shellcheck
  • /test test

The following commands are available to trigger optional jobs:

  • /test metal3-centos-e2e-basic-test-main
  • /test metal3-centos-e2e-feature-test-main-features
  • /test metal3-centos-e2e-feature-test-main-pivoting
  • /test metal3-centos-e2e-feature-test-main-remediation
  • /test metal3-centos-e2e-integration-test-main
  • /test metal3-dev-env-integration-test-centos-main
  • /test metal3-dev-env-integration-test-ubuntu-main
  • /test metal3-e2e-1-29-1-30-upgrade-test-main
  • /test metal3-e2e-clusterctl-upgrade-test-main
  • /test metal3-ubuntu-e2e-basic-test-main
  • /test metal3-ubuntu-e2e-feature-test-main-features
  • /test metal3-ubuntu-e2e-feature-test-main-pivoting
  • /test metal3-ubuntu-e2e-feature-test-main-remediation
  • /test metal3-ubuntu-e2e-integration-test-main

Use /test all to run the following jobs that were automatically triggered:

  • generate
  • gomod
  • manifestlint
Details

In response to this:

/test metal3-bmo-e2e-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@troy0820
Copy link
Copy Markdown
Contributor Author

troy0820 commented Aug 14, 2024

/retest

Not sure why the tests are not re-running, but I can push an empty commit.

@tuminoid
Copy link
Copy Markdown
Member

Thanks for the contribution! Let's squash those commits up.

Let's get some eyes on this.
/cc @kashifest @Rozzii @dtantsur @elfosardo

@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 15cc788 to 662161e Compare August 15, 2024 13:09
@kashifest
Copy link
Copy Markdown
Member

I am trying to understand this patch a bit, the original issue pointed by @s3rj1k was an edge case where code updated the status/BMH object even when there was no actual change in status, but it seems this patch is ignoring updating the object even when theres is any update on the status? Am I understanding it correctly?

@dtantsur
Copy link
Copy Markdown
Member

/cc @zaneb

@metal3-io-bot metal3-io-bot requested a review from zaneb August 27, 2024 12:03
@troy0820
Copy link
Copy Markdown
Contributor Author

I am trying to understand this patch a bit, the original issue pointed by @s3rj1k was an edge case where code updated the status/BMH object even when there was no actual change in status, but it seems this patch is ignoring updating the object even when theres is any update on the status? Am I understanding it correctly?

The object is updated but it doesn’t requeue the object in the event that the status last changed gets updated during a saveStatus. This was supposed to be handled by the predicate generation changed but seems to slip through.

Copy link
Copy Markdown
Member

@zaneb zaneb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this has any effect.

It's probably safe as long as we always remember to return Requeue:true whenever we need to requeue.
I think we do, but I also thought that we avoid writing unchanged statuses (as Dmitry pointed out), yet according the the bug report we do not. (OTOH, I'm not sure whether to believe this, because when asked where this happens the response was "check the code", and yet upon checking the code it's clearly fine.)

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller.go
@zaneb
Copy link
Copy Markdown
Member

zaneb commented Aug 27, 2024

/cc @andfasano, who appears to me to have already solved this exact issue in 2020 with #747.

@troy0820
Copy link
Copy Markdown
Contributor Author

Running the test that I added as part of this change works without the patch included. So I can dismiss this change and leave the test but we probably should close the issue if it is fixed.

@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 662161e to 611dffd Compare August 27, 2024 13:36
@troy0820 troy0820 changed the title 🐛Use predicate to not requeue when status changes from saveHostStatus 🌱Add test for baremetalhost controller updateEventHandler Aug 27, 2024
Comment thread controllers/metal3.io/baremetalhost_controller_test.go Outdated
Comment thread controllers/metal3.io/baremetalhost_controller_test.go Outdated
Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 611dffd to 2373f90 Compare August 27, 2024 14:42
@metal3-io-bot metal3-io-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 27, 2024
@zaneb
Copy link
Copy Markdown
Member

zaneb commented Aug 27, 2024

Reading over the bug report, the complaint was that we were doing no-op updates in the first place (although there is no evidence of this yet), thus causing extra work for other controllers that were watching the BMH.
There was no suggestion that BMO itself was doing too many reconciles after such an update. Extra reconciles for that and a much broader superset of cases were already eliminated by #747.

I'm fine with adding a test though. We could even test that all updates to the Status are ignored.

Copy link
Copy Markdown
Member

@Rozzii Rozzii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2024
@tuminoid
Copy link
Copy Markdown
Member

/cc @kashifest

@tuminoid
Copy link
Copy Markdown
Member

/cc @kashifest @zaneb @dtantsur @elfosardo
Can we get an approver for this?

@metal3-io-bot metal3-io-bot requested a review from zaneb September 27, 2024 13:10
Copy link
Copy Markdown
Member

@kashifest kashifest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kashifest

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2024
@metal3-io-bot metal3-io-bot merged commit 1ae5735 into metal3-io:main Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

saveHostStatus triggers even on unchanged object

8 participants