@@ -872,7 +872,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
872
872
case v1alpha1 .CSVPhaseInstallReady :
873
873
installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
874
874
if strategy == nil {
875
- // parseStrategiesAndUpdateStatus sets CSV status
876
875
return
877
876
}
878
877
@@ -897,7 +896,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
897
896
case v1alpha1 .CSVPhaseInstalling :
898
897
installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
899
898
if strategy == nil {
900
- // parseStrategiesAndUpdateStatus sets CSV status
901
899
return
902
900
}
903
901
@@ -907,7 +905,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
907
905
case v1alpha1 .CSVPhaseSucceeded :
908
906
installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
909
907
if strategy == nil {
910
- // parseStrategiesAndUpdateStatus sets CSV status
911
908
return
912
909
}
913
910
@@ -921,30 +918,29 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
921
918
met , statuses , err := a .requirementAndPermissionStatus (out )
922
919
if err != nil {
923
920
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 )
925
922
return
926
923
} else if ! met {
927
924
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 )
929
926
return
930
927
}
931
928
932
929
// Check if any generated resources are missing
933
930
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 )
935
932
return
936
933
}
937
934
938
935
// Check if it's time to refresh owned APIService certs
939
936
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 )
941
938
return
942
939
}
943
940
944
941
case v1alpha1 .CSVPhaseFailed :
945
942
installer , strategy , _ := a .parseStrategiesAndUpdateStatus (out )
946
943
if strategy == nil {
947
- // parseStrategiesAndUpdateStatus sets CSV status
948
944
return
949
945
}
950
946
@@ -985,26 +981,26 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
985
981
met , statuses , err := a .requirementAndPermissionStatus (out )
986
982
if err != nil {
987
983
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 )
989
985
return
990
986
} else if ! met {
991
987
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 )
993
989
return
994
990
}
995
991
996
992
// Check if any generated resources are missing
997
993
if resErr := a .checkAPIServiceResources (out , certs .PEMSHA256 ); len (resErr ) > 0 {
998
994
// Check if API services are adoptable. If not, keep CSV as Failed state
999
995
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 )
1001
997
return
1002
998
}
1003
999
}
1004
1000
1005
1001
// Check if it's time to refresh owned APIService certs
1006
1002
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 )
1008
1004
return
1009
1005
}
1010
1006
case v1alpha1 .CSVPhaseReplacing :
@@ -1104,7 +1100,7 @@ func (a *Operator) checkReplacementsAndUpdateStatus(csv *v1alpha1.ClusterService
1104
1100
if replacement := a .isBeingReplaced (csv , a .csvSet (csv .GetNamespace (), v1alpha1 .CSVPhaseAny )); replacement != nil {
1105
1101
a .Log .Infof ("newer ClusterServiceVersion replacing %s, no-op" , csv .SelfLink )
1106
1102
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 )
1108
1104
metrics .CSVUpgradeCount .Inc ()
1109
1105
1110
1106
return fmt .Errorf ("replacing" )
@@ -1120,24 +1116,24 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
1120
1116
if strategyInstalled && apiServicesInstalled {
1121
1117
// if there's no error, we're successfully running
1122
1118
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 )
1124
1120
}
1125
1121
return nil
1126
1122
}
1127
1123
1128
1124
// installcheck determined we can't progress (e.g. deployment failed to come up in time)
1129
1125
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 )
1131
1127
return strategyErr
1132
1128
}
1133
1129
1134
1130
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 )
1136
1132
return apiServiceErr
1137
1133
}
1138
1134
1139
1135
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 )
1141
1137
err := a .csvQueueSet .Requeue (csv .GetName (), csv .GetNamespace ())
1142
1138
if err != nil {
1143
1139
a .Log .Warn (err .Error ())
@@ -1147,7 +1143,7 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
1147
1143
}
1148
1144
1149
1145
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 )
1151
1147
return strategyErr
1152
1148
}
1153
1149
@@ -1158,7 +1154,7 @@ func (a *Operator) updateInstallStatus(csv *v1alpha1.ClusterServiceVersion, inst
1158
1154
func (a * Operator ) parseStrategiesAndUpdateStatus (csv * v1alpha1.ClusterServiceVersion ) (install.StrategyInstaller , install.Strategy , install.Strategy ) {
1159
1155
strategy , err := a .resolver .UnmarshalStrategy (csv .Spec .InstallStrategy )
1160
1156
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 )
1162
1158
return nil , nil , nil
1163
1159
}
1164
1160
0 commit comments