-
Notifications
You must be signed in to change notification settings - Fork 13
Stop FAR Agent on NHC Timeout Annotation #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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,13 +132,13 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct | |
| return emptyResult, err | ||
| } | ||
|
|
||
| // Check NHC timeout annotation | ||
| if isTimedOutByNHC(far) { | ||
| // Check NHC timeout annotation and stop the agent, since remediation is no longer relevant (most likely because fixed by a different remediator) | ||
| if r.Executor.Exists(far.GetUID()) && isTimedOutByNHC(far) { | ||
| r.Log.Info(utils.EventMessageRemediationStoppedByNHC) | ||
| r.Executor.Remove(far.GetUID()) | ||
| r.stopAgentAndGetCrConditionsStatus(far, node.Name) | ||
| utils.UpdateConditions(utils.RemediationInterruptedByNHC, far, r.Log) | ||
| commonEvents.RemediationStoppedByNHC(r.Recorder, far) | ||
| return emptyResult, err | ||
| return requeueImmediately, nil | ||
| } | ||
|
|
||
| // Add finalizer when the CR is created | ||
|
|
@@ -158,12 +158,7 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct | |
| r.Log.Info("CR's deletion timestamp is not zero, and FAR finalizer exists", "CR Name", req.Name) | ||
|
|
||
| if !meta.IsStatusConditionPresentAndEqual(far.Status.Conditions, commonConditions.SucceededType, metav1.ConditionTrue) { | ||
| processingCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.ProcessingType).Status | ||
| fenceAgentActionSucceededCondition := meta.FindStatusCondition(far.Status.Conditions, utils.FenceAgentActionSucceededType).Status | ||
| succeededCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.SucceededType).Status | ||
| r.Log.Info("FAR didn't finish remediate the node ", "CR Name", req.Name, "processing condition", processingCondition, | ||
| "fenceAgentActionSucceeded condition", fenceAgentActionSucceededCondition, "succeeded condition", succeededCondition) | ||
| r.Executor.Remove(far.GetUID()) | ||
| r.stopAgentAndGetCrConditionsStatus(far, node.Name) | ||
| } | ||
|
|
||
| // remove out-of-service taint when using OutOfServiceTaint remediation | ||
|
|
@@ -179,11 +174,11 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct | |
| return emptyResult, err | ||
| } | ||
| } | ||
| r.Log.Info("out-of-service taint was removed", "Node Name", req.Name) | ||
| r.Log.Info("out-of-service taint was removed", "Node Name", node.Name) | ||
| commonEvents.NormalEvent(r.Recorder, node, utils.EventReasonRemoveOutOfServiceTaint, utils.EventMessageRemoveOutOfServiceTaint) | ||
| } | ||
|
|
||
| // remove node's taints | ||
| // remove FAR remediation taint | ||
| taint := utils.CreateRemediationTaint() | ||
| if err := utils.RemoveTaint(r.Client, node.Name, taint); err != nil { | ||
| if apiErrors.IsConflict(err) { | ||
|
|
@@ -203,7 +198,7 @@ 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 remove finalizer from CR - %w", err) | ||
| } | ||
| r.Log.Info("Finalizer was removed", "CR Name", req.Name) | ||
| r.Log.Info("FAR Finalizer was removed", "CR Name", far.Name) | ||
| commonEvents.NormalEvent(r.Recorder, far, utils.EventReasonRemoveFinalizer, utils.EventMessageRemoveFinalizer) | ||
| return emptyResult, nil | ||
| } | ||
|
|
@@ -283,6 +278,16 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct | |
| return emptyResult, nil | ||
| } | ||
|
|
||
| // stopAgentAndGetCrStatus log FAR CR status and stops the agent's parallel execution | ||
| func (r *FenceAgentsRemediationReconciler) stopAgentAndGetCrConditionsStatus(far *v1alpha1.FenceAgentsRemediation, nodeName string) { | ||
| processingCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.ProcessingType).Status | ||
| fenceAgentActionSucceededCondition := meta.FindStatusCondition(far.Status.Conditions, utils.FenceAgentActionSucceededType).Status | ||
| succeededCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.SucceededType).Status | ||
| r.Log.Info("FAR agent was stopped", "Node Name", nodeName, "Agent Name", far.Spec.Agent, "processing condition", processingCondition, | ||
| "fenceAgentActionSucceeded condition", fenceAgentActionSucceededCondition, "succeeded condition", succeededCondition) | ||
| r.Executor.Remove(far.GetUID()) | ||
|
Comment on lines
+281
to
+288
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nil-pointer panic risk when reading CR conditions
- processingCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.ProcessingType).Status
- fenceAgentActionSucceededCondition := meta.FindStatusCondition(far.Status.Conditions, utils.FenceAgentActionSucceededType).Status
- succeededCondition := meta.FindStatusCondition(far.Status.Conditions, commonConditions.SucceededType).Status
+ var processingStatus, actionSucceededStatus, succeededStatus metav1.ConditionStatus
+
+ if c := meta.FindStatusCondition(far.Status.Conditions, commonConditions.ProcessingType); c != nil {
+ processingStatus = c.Status
+ }
+ if c := meta.FindStatusCondition(far.Status.Conditions, utils.FenceAgentActionSucceededType); c != nil {
+ actionSucceededStatus = c.Status
+ }
+ if c := meta.FindStatusCondition(far.Status.Conditions, commonConditions.SucceededType); c != nil {
+ succeededStatus = c.Status
+ }This guards against panics while preserving the intended log output.
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // isTimedOutByNHC checks if NHC set a timeout annotation on the CR | ||
| func isTimedOutByNHC(far *v1alpha1.FenceAgentsRemediation) bool { | ||
| if far != nil && far.Annotations != nil && far.DeletionTimestamp == nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
you add a condition here, and few lines below you change to requeue.... I think that's a significant unwanted change in execution flow, what happens on next reconcile?