Skip to content

Commit 41e5126

Browse files
committed
don't change CSV phase on service unavailable error
Signed-off-by: Joe Lanford <[email protected]>
1 parent 41469c0 commit 41e5126

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

pkg/controller/operators/olm/operator.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,15 +1565,21 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
15651565
out.SetPhaseWithEvent(v1alpha1.CSVPhasePending, v1alpha1.CSVReasonNeedsReinstall, "calculated deployment install is bad", now, a.recorder)
15661566
return
15671567
}
1568-
if installErr := a.updateInstallStatus(out, installer, strategy, v1alpha1.CSVPhaseInstalling, v1alpha1.CSVReasonWaiting); installErr == nil {
1569-
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Infof("install strategy successful")
1570-
} else {
1568+
if installErr := a.updateInstallStatus(out, installer, strategy, v1alpha1.CSVPhaseInstalling, v1alpha1.CSVReasonWaiting); installErr != nil {
1569+
// Re-sync if kube-apiserver was unavailable
1570+
if k8serrors.IsServiceUnavailable(installErr) {
1571+
logger.WithError(installErr).Info("could not update install status")
1572+
syncError = installErr
1573+
return
1574+
}
15711575
// Set phase to failed if it's been a long time since the last transition (5 minutes)
15721576
if out.Status.LastTransitionTime != nil && a.now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
15731577
logger.Warn("install timed out")
15741578
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, fmt.Sprintf("install timeout"), now, a.recorder)
1579+
return
15751580
}
15761581
}
1582+
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Infof("install strategy successful")
15771583

15781584
case v1alpha1.CSVPhaseSucceeded:
15791585
// Check if the current CSV is being replaced, return with replacing status if so
@@ -1622,6 +1628,12 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
16221628
return
16231629
}
16241630
if installErr := a.updateInstallStatus(out, installer, strategy, v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonComponentUnhealthy); installErr != nil {
1631+
// Re-sync if kube-apiserver was unavailable
1632+
if k8serrors.IsServiceUnavailable(installErr) {
1633+
logger.WithError(installErr).Info("could not update install status")
1634+
syncError = installErr
1635+
return
1636+
}
16251637
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Warnf("unhealthy component: %s", installErr)
16261638
return
16271639
}
@@ -1704,6 +1716,12 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
17041716
return
17051717
}
17061718
if installErr := a.updateInstallStatus(out, installer, strategy, v1alpha1.CSVPhasePending, v1alpha1.CSVReasonNeedsReinstall); installErr != nil {
1719+
// Re-sync if kube-apiserver was unavailable
1720+
if k8serrors.IsServiceUnavailable(installErr) {
1721+
logger.WithError(installErr).Info("could not update install status")
1722+
syncError = installErr
1723+
return
1724+
}
17071725
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Warnf("needs reinstall: %s", installErr)
17081726
}
17091727

@@ -1783,7 +1801,6 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
17831801
}
17841802

17851803
if err := findFirstError(k8serrors.IsServiceUnavailable, strategyErr, apiServiceErr, webhookErr); err != nil {
1786-
csv.SetPhaseWithEventIfChanged(v1alpha1.CSVPhasePending, v1alpha1.CSVReasonDetectedClusterChange, err.Error(), now, a.recorder)
17871804
return err
17881805
}
17891806

0 commit comments

Comments
 (0)