-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Closes #5565: Helm reconcile period from CR annotations or watches.yaml #5585
Closes #5565: Helm reconcile period from CR annotations or watches.yaml #5585
Conversation
ee557c0
to
2dc8eea
Compare
metadata: | ||
name: nginx-sample | ||
annotations: | ||
helm.operator-sdk/reconcile-period: "5s" |
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.
What happens if the reconciliation period not be informed?
What is the default behaviour?
Have we the same behaviour for Ansible and Helm in this case?
Also, is not it an issue for Ansible as well?
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 no reconcile period is specified in the CR annotations, then the default value is 1m as indicated here.
This behavior exists for Ansible: https://sdk.operatorframework.io/docs/building-operators/ansible/development-tips/#annotations-for-custom-resource.
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.
So, it shows that we also need to check/fix it for Ansible.
Historic we try to keep help/ansible working similar as much as possible since it helps keep both maintained, help us and the users switch easily between the languages as well.
Could we ensure the changes for ansible here as well?
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.
Can be a follow up either, but should we not. ensure that same for Ansible?
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.
@camilamacedo86: So we are now going to accept reconcile Period through 3 ways:
- from CR annotations
- command line flags
- through watches.yaml
The order of precedence imo should be CR annotations > watches.yaml > cmd line flags. We want it to be in sync with ansible, but ansible does not accept it from flags and neither does the hybrid helm implementation. We would want to eventually remove accepting it through cmd line flags, but I think that should be a follow up. From discussion with @VenkatRamaraju, looks like CR annotations override values fromwatches.yaml
in ansible. So I think we are good with that.
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.
a couple of suggestions and a question
@@ -388,9 +389,33 @@ func (r HelmOperatorReconciler) Reconcile(ctx context.Context, request reconcile | |||
Manifest: expectedRelease.Manifest, | |||
} | |||
err = r.updateResourceStatus(ctx, o, status) | |||
|
|||
// Parse the reconcile period from CR's annotations | |||
annotationsReconcilePeriod := parseReconcilePeriod(o) |
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.
For the record, o
is a horrible variable name for this but since it is an existing structure, I won't make you rewrite it here.
website/content/en/docs/building-operators/helm/reference/advanced_features/reconcile-period.md
Outdated
Show resolved
Hide resolved
|
||
The value that is present under this key must be in the h/m/s format. For example, 1h2m4s, 3m0s, 4s are all valid values, but 1x3m9s is invalid. | ||
|
||
**NOTE**: This is just one way of specifying the reconcile period for helm operators. Another way is using the `--reconcile-period` command line flag while running the operator. However, if both |
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.
**NOTE**: This is just one way of specifying the reconcile period for helm operators. Another way is using the `--reconcile-period` command line flag while running the operator. However, if both | |
**NOTE**: This is just one way of specifying the reconcile period for Helm-based operators. Another way is using the `--reconcile-period` command line flag while running the operator. However, if both |
website/content/en/docs/building-operators/helm/reference/advanced_features/reconcile-period.md
Outdated
Show resolved
Hide resolved
website/content/en/docs/building-operators/helm/reference/advanced_features/reconcile-period.md
Outdated
Show resolved
Hide resolved
2dc8eea
to
64bf0e5
Compare
@VenkatRamaraju if possible, can you also add this in https://github.com/operator-framework/helm-operator-plugins? |
@varshaprasad96 yup, I can do that. |
64bf0e5
to
7193943
Compare
// Parse the reconcile period from CR's annotations | ||
annotationsReconcilePeriod := parseReconcilePeriod(o) | ||
|
||
if annotationsReconcilePeriod != "" { |
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.
can we a have a small test that verifies the overriding hierarchy, just to make sure that when a flag is passed the annotation values (if present) override them?
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.
yup, I just added a couple of tests to verify the order of precedence and parsing of the field in the annotations.
I had to modify the signature of the function to make it easier to test.
7193943
to
f34d901
Compare
fed8ef4
to
1cd6231
Compare
23cf6e1
to
3bc5570
Compare
@@ -49,7 +49,7 @@ type WatchOptions struct { | |||
Namespace string | |||
GVK schema.GroupVersionKind | |||
ManagerFactory release.ManagerFactory | |||
ReconcilePeriod time.Duration | |||
ReconcilePeriod string |
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.
Can we revert this? Eventually watches struct would be exposed in hybrid implementation. To remain backwards compatible, let's avoid making changes to it.
6fcd943
to
cad82fa
Compare
9f4ff38
to
2c13436
Compare
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.
just one nit and /lgtm!
value from the custom resource annotations for helm operators. This value is set to | ||
then set to the 'reconcile-period' field of the reconciler to reconcile the cluster |
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.
Nit:
value from the custom resource annotations for helm operators. This value is set to | |
then set to the 'reconcile-period' field of the reconciler to reconcile the cluster | |
value from the custom resource annotations for helm operators. This value is | |
then set to the 'reconcile-period' field of the reconciler to reconcile the cluster |
Signed-off-by: Venkat Ramaraju <[email protected]>
2c13436
to
e7fd7b6
Compare
Description of the change:
helm.sdk.operatorframework.io/reconcile-period
key in the custom resource's annotations.watches.yaml
file.The value obtained from either of these two is set to the
RequeueAfter
field of the reconciler for Helm. If both are specified, then the CR annotations takes precedence.Motivation for the change:
Close #5565
Checklist
changelog/fragments
website/content/en/docs
Note:
As mentioned in my comment on the issue: this functionality already exists via a command line flag. This PR is to provide the user with the option of doing the same in the CR annotations or
watches.yaml
, which there seems to be a demand for. This feature already exists for the Ansible-based operator, so I thought it would be a good idea to do the same for the Helm-based operator.The current order of precedence is: flag < watches < CR annotations.