@@ -872,7 +872,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
872872 case v1alpha1 .CSVPhaseInstallReady :
873873 installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
874874 if strategy == nil {
875- // parseStrategiesAndUpdateStatus sets CSV status
876875 return
877876 }
878877
@@ -897,7 +896,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
897896 case v1alpha1 .CSVPhaseInstalling :
898897 installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
899898 if strategy == nil {
900- // parseStrategiesAndUpdateStatus sets CSV status
901899 return
902900 }
903901
@@ -907,7 +905,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
907905 case v1alpha1 .CSVPhaseSucceeded :
908906 installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
909907 if strategy == nil {
910- // parseStrategiesAndUpdateStatus sets CSV status
911908 return
912909 }
913910
@@ -921,30 +918,29 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
921918 met , statuses , err := a .requirementAndPermissionStatus (out )
922919 if err != nil {
923920 logger .Info ("invalid install strategy" )
924- out .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now )
921+ out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now , a . recorder )
925922 return
926923 } else if ! met {
927924 out .SetRequirementStatus (statuses )
928- out .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements no longer met" ), now )
925+ out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements no longer met" ), now , a . recorder )
929926 return
930927 }
931928
932929 // Check if any generated resources are missing
933930 if resErr := a .checkAPIServiceResources (out , certs .PEMSHA256 ); len (resErr ) > 0 {
934- out .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonAPIServiceResourceIssue , resErr [0 ].Error (), now )
931+ out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonAPIServiceResourceIssue , resErr [0 ].Error (), now , a . recorder )
935932 return
936933 }
937934
938935 // Check if it's time to refresh owned APIService certs
939936 if a .shouldRotateCerts (out ) {
940- out .SetPhase (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now )
937+ out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now , a . recorder )
941938 return
942939 }
943940
944941 case v1alpha1 .CSVPhaseFailed :
945942 installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
946943 if strategy == nil {
947- // parseStrategiesAndUpdateStatus sets CSV status
948944 return
949945 }
950946
@@ -985,26 +981,26 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
985981 met , statuses , err := a .requirementAndPermissionStatus (out )
986982 if err != nil {
987983 logger .Warn ("invalid install strategy" )
988- out .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now )
984+ out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now , a . recorder )
989985 return
990986 } else if ! met {
991987 out .SetRequirementStatus (statuses )
992- out .SetPhase (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements not met" ), now )
988+ out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements not met" ), now , a . recorder )
993989 return
994990 }
995991
996992 // Check if any generated resources are missing
997993 if resErr := a .checkAPIServiceResources (out , certs .PEMSHA256 ); len (resErr ) > 0 {
998994 // Check if API services are adoptable. If not, keep CSV as Failed state
999995 if a .apiServiceResourceErrorsActionable (resErr ) {
1000- out .SetPhase (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonAPIServiceResourcesNeedReinstall , resErr [0 ].Error (), now )
996+ out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonAPIServiceResourcesNeedReinstall , resErr [0 ].Error (), now , a . recorder )
1001997 return
1002998 }
1003999 }
10041000
10051001 // Check if it's time to refresh owned APIService certs
10061002 if a .shouldRotateCerts (out ) {
1007- out .SetPhase (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now )
1003+ out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now , a . recorder )
10081004 return
10091005 }
10101006 case v1alpha1 .CSVPhaseReplacing :
@@ -1104,7 +1100,7 @@ func (a *Operator) checkReplacementsAndUpdateStatus(csv *v1alpha1.ClusterService
11041100 if replacement := a .isBeingReplaced (csv , a .csvSet (csv .GetNamespace (), v1alpha1 .CSVPhaseAny )); replacement != nil {
11051101 a .Log .Infof ("newer ClusterServiceVersion replacing %s, no-op" , csv .SelfLink )
11061102 msg := fmt .Sprintf ("being replaced by csv: %s" , replacement .SelfLink )
1107- csv .SetPhase (v1alpha1 .CSVPhaseReplacing , v1alpha1 .CSVReasonBeingReplaced , msg , timeNow ())
1103+ csv .SetPhaseWithEvent (v1alpha1 .CSVPhaseReplacing , v1alpha1 .CSVReasonBeingReplaced , msg , timeNow (), a . recorder )
11081104 metrics .CSVUpgradeCount .Inc ()
11091105
11101106 return fmt .Errorf ("replacing" )
@@ -1120,24 +1116,24 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
11201116 if strategyInstalled && apiServicesInstalled {
11211117 // if there's no error, we're successfully running
11221118 if csv .Status .Phase != v1alpha1 .CSVPhaseSucceeded {
1123- csv .SetPhase (v1alpha1 .CSVPhaseSucceeded , v1alpha1 .CSVReasonInstallSuccessful , "install strategy completed with no errors" , now )
1119+ csv .SetPhaseWithEvent (v1alpha1 .CSVPhaseSucceeded , v1alpha1 .CSVReasonInstallSuccessful , "install strategy completed with no errors" , now , a . recorder )
11241120 }
11251121 return nil
11261122 }
11271123
11281124 // installcheck determined we can't progress (e.g. deployment failed to come up in time)
11291125 if install .IsErrorUnrecoverable (strategyErr ) {
1130- csv .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInstallCheckFailed , fmt .Sprintf ("install failed: %s" , strategyErr ), now )
1126+ csv .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInstallCheckFailed , fmt .Sprintf ("install failed: %s" , strategyErr ), now , a . recorder )
11311127 return strategyErr
11321128 }
11331129
11341130 if apiServiceErr != nil {
1135- csv .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonAPIServiceInstallFailed , fmt .Sprintf ("APIService install failed: %s" , apiServiceErr ), now )
1131+ csv .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonAPIServiceInstallFailed , fmt .Sprintf ("APIService install failed: %s" , apiServiceErr ), now , a . recorder )
11361132 return apiServiceErr
11371133 }
11381134
11391135 if ! apiServicesInstalled {
1140- csv .SetPhase (requeuePhase , requeueConditionReason , fmt .Sprintf ("APIServices not installed" ), now )
1136+ csv .SetPhaseWithEvent (requeuePhase , requeueConditionReason , fmt .Sprintf ("APIServices not installed" ), now , a . recorder )
11411137 err := a .csvQueueSet .Requeue (csv .GetName (), csv .GetNamespace ())
11421138 if err != nil {
11431139 a .Log .Warn (err .Error ())
@@ -1147,7 +1143,7 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
11471143 }
11481144
11491145 if strategyErr != nil {
1150- csv .SetPhase (requeuePhase , requeueConditionReason , fmt .Sprintf ("installing: %s" , strategyErr ), now )
1146+ csv .SetPhaseWithEvent (requeuePhase , requeueConditionReason , fmt .Sprintf ("installing: %s" , strategyErr ), now , a . recorder )
11511147 return strategyErr
11521148 }
11531149
@@ -1158,7 +1154,7 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
11581154func (a * Operator ) parseStrategiesAndUpdateStatus (csv * v1alpha1.ClusterServiceVersion ) (install.StrategyInstaller , install.Strategy , install.Strategy ) {
11591155 strategy , err := a .resolver .UnmarshalStrategy (csv .Spec .InstallStrategy )
11601156 if err != nil {
1161- csv .SetPhase (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err ), timeNow ())
1157+ csv .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err ), timeNow (), a . recorder )
11621158 return nil , nil , nil
11631159 }
11641160
0 commit comments