Skip to content

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Jun 18, 2023

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 18, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 18, 2023
@Fedosin Fedosin changed the title Update provider if (and only if) it's spec has been changed 🐛 Update provider if (and only if) it's spec has been changed Jun 18, 2023
@Fedosin Fedosin changed the title 🐛 Update provider if (and only if) it's spec has been changed 🐛 Update provider components if (and only if) it's spec has been changed Jun 18, 2023
@Fedosin Fedosin force-pushed the applied_spec_hash branch from 2e83ed8 to b5590cb Compare June 18, 2023 11:55
@Fedosin Fedosin force-pushed the applied_spec_hash branch from b5590cb to 2d1ff59 Compare June 19, 2023 10:33
return ctrl.Result{}, err
}

if typedProvider.GetAnnotations()[appliedSpecHashAnnotation] == specHash {
Copy link
Contributor

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

Copy link
Contributor Author

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

Fedosin added 3 commits June 20, 2023 11:04
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.
@Fedosin Fedosin force-pushed the applied_spec_hash branch from 2d1ff59 to fbe6ef4 Compare June 20, 2023 09:04
@Fedosin
Copy link
Contributor Author

Fedosin commented Jun 20, 2023

/retest

@Fedosin Fedosin changed the title 🐛 Update provider components if (and only if) it's spec has been changed 🐛 Update provider components if (and only if) its spec has been changed Jun 20, 2023
Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/approve

cc @damdo @furkatgofurov7

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 20, 2023
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 21, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e140c9eea730d59854702a02d8e3f278b0aaf024

@k8s-ci-robot k8s-ci-robot merged commit 996d5d4 into kubernetes-sigs:main Jun 21, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operator doesn't reconcile providers if their spec values changed

4 participants