-
Notifications
You must be signed in to change notification settings - Fork 108
🐛 Update provider components if (and only if) its spec has been changed #168
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
Conversation
2e83ed8
to
b5590cb
Compare
b5590cb
to
2d1ff59
Compare
return ctrl.Result{}, err | ||
} | ||
|
||
if typedProvider.GetAnnotations()[appliedSpecHashAnnotation] == specHash { |
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.
If I remember it right, GetAnnotations()
can still return nil
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.
Yeah, it can, but it doesn't matter. We can get values from nil maps. Here is an example I wrote: https://go.dev/play/p/pUL9u7U5OyR
To prevent duplicate reconciliation we calculate last applied spec hash and store it in a provider annotation. For next reconciliations we calculate the hash again. If it's the same as in the annotation, we skip further steps and stop immediately.
Now this logic is in the spec hash check, i.e. if provider version has changed, spec hash will be different. So it doesn't make sense to keep duplicate code that does the same.
2d1ff59
to
fbe6ef4
Compare
/retest |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexander-demicev The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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
LGTM label has been added. Git tree hash: e140c9eea730d59854702a02d8e3f278b0aaf024
|
What this PR does / why we need it:
Now we update provider components only if it's version has changed, but there are other cases where we need to do the same. For instance, when we update its DeploymentSpec or ManagementSpec.
Also we should reconcile providers if their spec is the same as for the last applied version.
To fix it we calculate last applied spec hash and store it in a provider annotation. For next reconciliations we calculate the hash again. If it's the same as in the annotation, we skip further steps and stop immediately.
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 #156