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

🐛 Fix incorrect handling when removing from the end of the triggers array #1768

Merged
merged 3 commits into from
May 4, 2021

Conversation

coderanger
Copy link
Contributor

@coderanger coderanger commented Apr 30, 2021

Fixes #1699 and includes a test to make sure it doesn't come back.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)
  • Tests have been added
  • Changelog has been updated

@coderanger
Copy link
Contributor Author

This probably will fail in CI since I need to add stuff to the GHA config to install the envtest binaries for functional tests, but I will do that tomorrow. The fix itself can be cherrypicked if getting the envtest stuff in order ends up being a blocker.

@zroubalik
Copy link
Member

This probably will fail in CI since I need to add stuff to the GHA config to install the envtest binaries for functional tests, but I will do that tomorrow. The fix itself can be cherrypicked if getting the envtest stuff in order ends up being a blocker.

Thanks a lot for the fix! Add an entry to the changelog as well please.

@@ -111,7 +111,8 @@ func (r *ScaledObjectReconciler) updateHPAIfNeeded(logger logr.Logger, scaledObj
return err
}

if !equality.Semantic.DeepDerivative(hpa.Spec, foundHpa.Spec) {
// DeepDerivative ignores extra entries in arrays which makes removing the last trigger not update things, so trigger and update any time the metrics count is different.
Copy link
Member

Choose a reason for hiding this comment

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

Wow 🤦

@coderanger
Copy link
Contributor Author

@zroubalik I'm guessing I'll need to split that last commit into it's own PR, merge that, then rebuild this?

@zroubalik
Copy link
Member

This PR needs to be rebased in order to get the new build tools image (the location was changed from kedacore/build-tools to ghrc.io/kedacore/build-tools) and use kubebuilder installed on that image.

…dacore#1699.

Test is currently failing, as expected.

Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
…rray.

DeepDerivative considers it fine if the found HPA has extra elements in the array as long as the ones that are there in the computed HPA match the found. In our case, that causes updating the HPA to be skipped if you remove the last trigger (or any number as long as they are at the end). Checking the lengths first is quick and should cover all of these wonky cases.

Fixes kedacore#1699.

Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
@coderanger
Copy link
Contributor Author

Looks like the tests are happy, so we should be all set to write more controller functional tests in the future as needed :)

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this!

@zroubalik zroubalik merged commit 24dc0a8 into kedacore:main May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing triggers from ScaledObject doesn't reflect in the HPA it manages
2 participants