@@ -1565,15 +1565,21 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1565
1565
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsReinstall , "calculated deployment install is bad" , now , a .recorder )
1566
1566
return
1567
1567
}
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
+ }
1571
1575
// Set phase to failed if it's been a long time since the last transition (5 minutes)
1572
1576
if out .Status .LastTransitionTime != nil && a .now ().Sub (out .Status .LastTransitionTime .Time ) >= 5 * time .Minute {
1573
1577
logger .Warn ("install timed out" )
1574
1578
out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInstallCheckFailed , fmt .Sprintf ("install timeout" ), now , a .recorder )
1579
+ return
1575
1580
}
1576
1581
}
1582
+ logger .WithField ("strategy" , out .Spec .InstallStrategy .StrategyName ).Infof ("install strategy successful" )
1577
1583
1578
1584
case v1alpha1 .CSVPhaseSucceeded :
1579
1585
// 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
1622
1628
return
1623
1629
}
1624
1630
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
+ }
1625
1637
logger .WithField ("strategy" , out .Spec .InstallStrategy .StrategyName ).Warnf ("unhealthy component: %s" , installErr )
1626
1638
return
1627
1639
}
@@ -1704,6 +1716,12 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1704
1716
return
1705
1717
}
1706
1718
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
+ }
1707
1725
logger .WithField ("strategy" , out .Spec .InstallStrategy .StrategyName ).Warnf ("needs reinstall: %s" , installErr )
1708
1726
}
1709
1727
@@ -1783,7 +1801,6 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
1783
1801
}
1784
1802
1785
1803
if err := findFirstError (k8serrors .IsServiceUnavailable , strategyErr , apiServiceErr , webhookErr ); err != nil {
1786
- csv .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonDetectedClusterChange , err .Error (), now , a .recorder )
1787
1804
return err
1788
1805
}
1789
1806
0 commit comments