Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱Add test for baremetalhost controller updateEventHandler #1881

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

troy0820
Copy link

@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
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign honza for approval. For more information see the Kubernetes Code Review Process.

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

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 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
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.

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
@troy0820 troy0820 force-pushed the troy0820/saveHostStatus-predicate branch from 7fe7bfe to 1e5696c Compare August 13, 2024 19:09
@tuminoid
Copy link
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
Author

/test metal3-bmo-e2e-test

@metal3-io-bot
Copy link
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

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
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
Member

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

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

@kashifest
Copy link
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
Member

/cc @zaneb

@troy0820
Copy link
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
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.)

controllers/metal3.io/baremetalhost_controller.go Outdated Show resolved Hide resolved
controllers/metal3.io/baremetalhost_controller.go Outdated Show resolved Hide resolved
@zaneb
Copy link
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
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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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