-
Notifications
You must be signed in to change notification settings - Fork 562
(fix)InstallPlan: Do not tranisition IP to failed on OG/SA failure #2215
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
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 |
---|---|---|
|
@@ -1387,28 +1387,36 @@ func (o *Operator) syncInstallPlans(obj interface{}) (syncError error) { | |
|
||
querier := o.serviceAccountQuerier.NamespaceQuerier(plan.GetNamespace()) | ||
ref, err := querier() | ||
if err != nil { | ||
|
||
// Retry sync if non-fatal error | ||
if !scoped.IsOperatorGroupError(err) { | ||
syncError = fmt.Errorf("attenuated service account query failed - %v", err) | ||
return | ||
} | ||
|
||
// Mark the InstallPlan as failed for a fatal Operator Group related error | ||
logger.Infof("attenuated service account query failed - %v", err) | ||
ipFailError := fmt.Errorf("invalid operator group - %v", err) | ||
|
||
if err := o.transitionInstallPlanToFailed(plan, logger, v1alpha1.InstallPlanReasonInstallCheckFailed, ipFailError.Error()); err != nil { | ||
// retry for failure to update status | ||
out := plan.DeepCopy() | ||
if err != nil { | ||
// Set status condition/message and retry sync if any error | ||
ipFailError := fmt.Errorf("attenuated service account query failed - %v", err) | ||
logger.Infof(ipFailError.Error()) | ||
_, err := o.setInstallPlanInstalledCond(out, v1alpha1.InstallPlanReasonInstallCheckFailed, err.Error(), logger) | ||
if err != nil { | ||
syncError = err | ||
return | ||
} | ||
|
||
// Requeue subscription to propagate SubscriptionInstallPlanFailed condtion to subscription | ||
o.requeueSubscriptionForInstallPlan(plan, logger) | ||
|
||
syncError = ipFailError | ||
return | ||
} else { | ||
// reset condition/message if it had been set in previous sync. This condition is being reset since any delay in the next steps | ||
// (bundle unpacking/plan step errors being retried for a duration) could lead to this condition sticking around, even after | ||
// the serviceAccountQuerier returns no error since the error has been resolved (by creating the required resources), which would | ||
// be confusing to the user | ||
Comment on lines
+1404
to
+1407
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. We should probably add a unit test case to test this path and check that this holds, i.e pass an IP with the condtion 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. Added an e2e test for this instead since an e2e test feels more natural for this. |
||
|
||
// NOTE: this makes the assumption that the InstallPlanInstalledCheckFailed reason is only set in the previous if clause, which is | ||
// true in the current iteration of the catalog operator. Any future implementation change that aims at setting the reason as | ||
// InstallPlanInstalledCheckFailed must make sure that either this assumption is not breached, or the condition being set elsewhere | ||
// is not being unset here unintentionally. | ||
if cond := out.Status.GetCondition(v1alpha1.InstallPlanInstalled); cond.Reason == v1alpha1.InstallPlanReasonInstallCheckFailed { | ||
plan, err = o.setInstallPlanInstalledCond(out, v1alpha1.InstallPlanConditionReason(corev1.ConditionUnknown), "", logger) | ||
if err != nil { | ||
syncError = err | ||
return | ||
} | ||
} | ||
} | ||
|
||
if ref != nil { | ||
|
@@ -1553,6 +1561,18 @@ func (o *Operator) requeueSubscriptionForInstallPlan(plan *v1alpha1.InstallPlan, | |
} | ||
} | ||
|
||
func (o *Operator) setInstallPlanInstalledCond(ip *v1alpha1.InstallPlan, reason v1alpha1.InstallPlanConditionReason, message string, logger *logrus.Entry) (*v1alpha1.InstallPlan, error) { | ||
now := o.now() | ||
ip.Status.SetCondition(v1alpha1.ConditionFailed(v1alpha1.InstallPlanInstalled, reason, message, &now)) | ||
outIP, err := o.client.OperatorsV1alpha1().InstallPlans(ip.GetNamespace()).UpdateStatus(context.TODO(), ip, metav1.UpdateOptions{}) | ||
if err != nil { | ||
logger = logger.WithField("updateError", err.Error()) | ||
logger.Errorf("error updating InstallPlan status") | ||
return nil, nil | ||
} | ||
return outIP, nil | ||
} | ||
|
||
type installPlanTransitioner interface { | ||
ExecutePlan(*v1alpha1.InstallPlan) error | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.