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

End Reconcile after Finalizer Addition #64

Conversation

razo7
Copy link
Member

@razo7 razo7 commented Jul 5, 2023

The reconcile should end when a finalizer has been added. Without ending the reconcile a new reconcile will always be triggered and will result in a duplicate reboot to the node (until FAR would have a status to the CR).

ECOPROJECT-1415

The reconcile should end when a finalizer has been added. Without ending the reconcile a new reconcile will allways be triggered and will result in a duplicate reboot to the node (until FAR would have a status to the CR)
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 5, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the approved label Jul 5, 2023
@razo7
Copy link
Member Author

razo7 commented Jul 5, 2023

/test 4.13-openshift-e2e

@@ -106,6 +106,10 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct
if err := r.Client.Update(context.Background(), far); err != nil {
return emptyResult, fmt.Errorf("failed to add finalizer to the CR - %w", err)
}
r.Log.Info("Finalizer was added", "CR Name", req.Name)
return emptyResult, nil
Copy link
Member

Choose a reason for hiding this comment

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

I do not understand how this prevents a duplicate reboot. Can you explain please?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought the PR description would explain it, but I will try again.

Before this change on a valid CR (by name), then the first reconcile will finish with emptyResult after running all the reconcile logic (including the FA execution). But since on the last (and first) reconcile call we have been updating the CR by adding a finalizer, then it triggers a second reconcile.
On this second reconcile it will try to execute the FA, since the CR doesn't have a status or any if block that we sparse the CR from running again the FA (it probably will fail until it eventually succeeds to reboot the node).
The reconcile won't finish be requeued until the FA will return success response, and we will end up with duplicate reboot.

After this change when we add the finalizer then we finish the reconcile with emptyResult. Since the CR was updated then on the second reconcile run will add taint and exeucte FA for the first time. Therefore, the PR change would stop the FA execution from the first reconcile run.

I am aware that other stuff, such as remediating the node which host the FAR PR, could trigger the reconcile again, and we will end up with another reboot but this problem will be resolved later with ECOPROJECT-1411

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, I mixed 1411 and 1415, sorry.

By returning the empty result here you only implicitly requeue because you know that it will happen because of the CR modification. I would prefer an explicit requeue. Did you try that? Or will it be reconciled twice then? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

By returning the empty result here you only implicitly requeue because you know that it will happen because of the CR modification

Correct.

Did you try that? Or will it be reconciled twice then?

Correct again, see https://github.com/medik8s/fence-agents-remediation/pull/64/files#diff-05147ee3f0d225b5a60754b8b9bff2c569deb0a9d7eaddae33af680291d493a1R111-R112. I tried with Requeue: true or RequeueAfter: 1 * time.Second, and it resulted in a second reconcile. So until there's a status this PR will add this workaround...

Copy link
Member

Choose a reason for hiding this comment

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

ack, thx

@razo7
Copy link
Member Author

razo7 commented Jul 6, 2023

/test 4.13-openshift-e2e

@@ -106,6 +106,10 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct
if err := r.Client.Update(context.Background(), far); err != nil {
return emptyResult, fmt.Errorf("failed to add finalizer to the CR - %w", err)
}
r.Log.Info("Finalizer was added", "CR Name", req.Name)
return emptyResult, nil
Copy link
Member

Choose a reason for hiding this comment

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

ack, thx

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7, slintes

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

@razo7 razo7 marked this pull request as ready for review July 9, 2023 14:47
@openshift-ci openshift-ci bot requested review from mshitrit and slintes July 9, 2023 14:47
@openshift-merge-robot openshift-merge-robot merged commit 9893bf8 into medik8s:main Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants