-
Notifications
You must be signed in to change notification settings - Fork 95
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
Allow GeneratingHandlers to skip Apply if resource version didn't change #341
Allow GeneratingHandlers to skip Apply if resource version didn't change #341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good. I don't love adding more code in generated templates, but this is a good approach to solving the problem.
Also, I didn't mark this but I would be forever grateful if you added function comments to GeneratingHandler since you are already in the package.
Co-authored-by: Kevin Joiner <[email protected]>
Co-authored-by: Kevin Joiner <[email protected]>
I'm sorry I missed this comment when I first addressed your feedback. It's done now, please take another look, thanks! |
…nge (rancher#341) * Allow GeneratingHandlers to skip Apply if resource version didn't change * Run go generate * Add call count to FakeApply * Add test for UniqueApplyForResourceVersion * Simplify error handling Co-authored-by: Kevin Joiner <[email protected]> * Make generated code more readable Co-authored-by: Kevin Joiner <[email protected]> * Rename constant * Rename seenResourceVersion to storeResourceVersion * go generate * Add comments to code generator * Run go generate * Upgrade golangci-lint GitHub action, since it always fails now --------- Co-authored-by: Kevin Joiner <[email protected]>
…nge (rancher#341) * Allow GeneratingHandlers to skip Apply if resource version didn't change * Run go generate * Add call count to FakeApply * Add test for UniqueApplyForResourceVersion * Simplify error handling Co-authored-by: Kevin Joiner <[email protected]> * Make generated code more readable Co-authored-by: Kevin Joiner <[email protected]> * Rename constant * Rename seenResourceVersion to storeResourceVersion * go generate * Add comments to code generator * Run go generate * Upgrade golangci-lint GitHub action, since it always fails now --------- Co-authored-by: Kevin Joiner <[email protected]>
…nge (rancher#341) * Allow GeneratingHandlers to skip Apply if resource version didn't change * Run go generate * Add call count to FakeApply * Add test for UniqueApplyForResourceVersion * Simplify error handling Co-authored-by: Kevin Joiner <[email protected]> * Make generated code more readable Co-authored-by: Kevin Joiner <[email protected]> * Rename constant * Rename seenResourceVersion to storeResourceVersion * go generate * Add comments to code generator * Run go generate * Upgrade golangci-lint GitHub action, since it always fails now --------- Co-authored-by: Kevin Joiner <[email protected]>
…nge (rancher#341) * Allow GeneratingHandlers to skip Apply if resource version didn't change * Run go generate * Add call count to FakeApply * Add test for UniqueApplyForResourceVersion * Simplify error handling Co-authored-by: Kevin Joiner <[email protected]> * Make generated code more readable Co-authored-by: Kevin Joiner <[email protected]> * Rename constant * Rename seenResourceVersion to storeResourceVersion * go generate * Add comments to code generator * Run go generate * Upgrade golangci-lint GitHub action, since it always fails now --------- Co-authored-by: Kevin Joiner <[email protected]>
…nge (rancher#341) * Allow GeneratingHandlers to skip Apply if resource version didn't change * Run go generate * Add call count to FakeApply * Add test for UniqueApplyForResourceVersion * Simplify error handling Co-authored-by: Kevin Joiner <[email protected]> * Make generated code more readable Co-authored-by: Kevin Joiner <[email protected]> * Rename constant * Rename seenResourceVersion to storeResourceVersion * go generate * Add comments to code generator * Run go generate * Upgrade golangci-lint GitHub action, since it always fails now --------- Co-authored-by: Kevin Joiner <[email protected]>
Extends
GeneratingHandlerOptions
to allow a newUniqueApplyForResourceVersion
, which will keep track of the latest resource version for each individual resource that was handled, avoiding subsequent calls to Apply if the first one was successful. The goal is to limit the number of Apply is called with the same inputs, reducing the computation costs. However, this means that handlers must be deterministic, in the sense that they must produce the same object list for the same input resource, hence this option must be carefully enabled on a case by case basis. It has no impact on other users if the option is not enabled.We have successfully tested this feature on Fleet's Bundle and GitRepo generating handlers (see rancher/fleet#1964 for an example usage), while trying to mitigate the effect of over-firing handlers (we are also working towards the root cause of the over-firing, which may be partially caused by the use of
Enqueue
).