@@ -106,13 +106,6 @@ func checkForUnexpectedFieldChange(a, b operatorsv1alpha1.Operator) bool {
106106func (r * OperatorReconciler ) reconcile (ctx context.Context , op * operatorsv1alpha1.Operator ) (ctrl.Result , error ) {
107107 // validate spec
108108 if err := validators .ValidateOperatorSpec (op ); err != nil {
109- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
110- Type : operatorsv1alpha1 .TypeReady ,
111- Status : metav1 .ConditionFalse ,
112- Reason : operatorsv1alpha1 .ReasonInvalidSpec ,
113- Message : err .Error (),
114- ObservedGeneration : op .GetGeneration (),
115- })
116109 // Set the TypeResolved condition to Unknown to indicate that the resolution
117110 // hasn't been attempted yet, due to the spec being invalid.
118111 op .Status .ResolvedBundleResource = ""
@@ -128,13 +121,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
128121 // run resolution
129122 solution , err := r .Resolver .Resolve (ctx )
130123 if err != nil {
131- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
132- Type : operatorsv1alpha1 .TypeReady ,
133- Status : metav1 .ConditionFalse ,
134- Reason : operatorsv1alpha1 .ReasonResolutionFailed ,
135- Message : err .Error (),
136- ObservedGeneration : op .GetGeneration (),
137- })
138124 op .Status .ResolvedBundleResource = ""
139125 apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
140126 Type : operatorsv1alpha1 .TypeResolved ,
@@ -150,13 +136,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
150136 // Operator's desired package name.
151137 bundleEntity , err := r .getBundleEntityFromSolution (solution , op .Spec .PackageName )
152138 if err != nil {
153- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
154- Type : operatorsv1alpha1 .TypeReady ,
155- Status : metav1 .ConditionFalse ,
156- Reason : operatorsv1alpha1 .ReasonBundleLookupFailed ,
157- Message : err .Error (),
158- ObservedGeneration : op .GetGeneration (),
159- })
160139 op .Status .ResolvedBundleResource = ""
161140 apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
162141 Type : operatorsv1alpha1 .TypeResolved ,
@@ -171,13 +150,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
171150 // Get the bundle image reference for the bundle
172151 bundleImage , err := bundleEntity .BundlePath ()
173152 if err != nil {
174- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
175- Type : operatorsv1alpha1 .TypeReady ,
176- Status : metav1 .ConditionFalse ,
177- Reason : operatorsv1alpha1 .ReasonBundleLookupFailed ,
178- Message : err .Error (),
179- ObservedGeneration : op .GetGeneration (),
180- })
181153 op .Status .ResolvedBundleResource = ""
182154 apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
183155 Type : operatorsv1alpha1 .TypeResolved ,
@@ -203,31 +175,18 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
203175 // image we just looked up in the solution.
204176 dep := r .generateExpectedBundleDeployment (* op , bundleImage )
205177 if err := r .ensureBundleDeployment (ctx , dep ); err != nil {
206- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
207- Type : operatorsv1alpha1 .TypeReady ,
208- Status : metav1 .ConditionFalse ,
209- Reason : operatorsv1alpha1 .ReasonInstallationFailed ,
210- Message : err .Error (),
211- ObservedGeneration : op .GetGeneration (),
212- })
178+ // originally Reason: operatorsv1alpha1.ReasonInstallationFailed
213179 return ctrl.Result {}, err
214180 }
215181
216182 // convert existing unstructured object into bundleDeployment for easier mapping of status.
217183 existingTypedBundleDeployment := & rukpakv1alpha1.BundleDeployment {}
218184 if err := runtime .DefaultUnstructuredConverter .FromUnstructured (dep .UnstructuredContent (), existingTypedBundleDeployment ); err != nil {
219- apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
220- Type : operatorsv1alpha1 .TypeReady ,
221- Status : metav1 .ConditionUnknown ,
222- Reason : operatorsv1alpha1 .ReasonInstallationStatusUnknown ,
223- Message : err .Error (),
224- ObservedGeneration : op .GetGeneration (),
225- })
185+ // originally Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown
226186 return ctrl.Result {}, err
227187 }
228188
229189 // set the status of the operator based on the respective bundle deployment status conditions.
230- apimeta .SetStatusCondition (& op .Status .Conditions , mapBDStatusToReadyCondition (existingTypedBundleDeployment , op .GetGeneration ()))
231190 return ctrl.Result {}, nil
232191}
233192
@@ -359,43 +318,6 @@ func verifyBDStatus(dep *rukpakv1alpha1.BundleDeployment) (metav1.ConditionStatu
359318 return metav1 .ConditionUnknown , fmt .Sprintf ("could not determine the state of BundleDeployment %s" , dep .Name )
360319}
361320
362- // mapBDStatusToReadyCondition returns the operator object's "TypeReady" condition based on the bundle deployment statuses.
363- func mapBDStatusToReadyCondition (existingBD * rukpakv1alpha1.BundleDeployment , observedGeneration int64 ) metav1.Condition {
364- // if BundleDeployment status is stale, return an unknown condition.
365- if isBundleDepStale (existingBD ) {
366- return metav1.Condition {
367- Type : operatorsv1alpha1 .TypeReady ,
368- Status : metav1 .ConditionUnknown ,
369- Reason : operatorsv1alpha1 .ReasonInstallationStatusUnknown ,
370- Message : fmt .Sprintf ("waiting for BundleDeployment %q status to be updated. BundleDeployment conditions out of date." , existingBD .Name ),
371- ObservedGeneration : observedGeneration ,
372- }
373- }
374- // update operator status:
375- // 1. If the Operator "Ready" status is "Unknown": The status of successful bundleDeployment is unknown, wait till Rukpak updates the BD status.
376- // 2. If the Operator "Ready" status is "True": Update the "successful resolution" status and return the result.
377- // 3. If the Operator "Ready" status is "False": There is error observed from Rukpak. Update the status accordingly.
378- status , message := verifyBDStatus (existingBD )
379- var reason string
380-
381- switch status {
382- case metav1 .ConditionTrue :
383- reason = operatorsv1alpha1 .ReasonInstallationSucceeded
384- case metav1 .ConditionFalse :
385- reason = operatorsv1alpha1 .ReasonInstallationFailed
386- default :
387- reason = operatorsv1alpha1 .ReasonInstallationStatusUnknown
388- }
389-
390- return metav1.Condition {
391- Type : operatorsv1alpha1 .TypeReady ,
392- Status : status ,
393- Reason : reason ,
394- Message : message ,
395- ObservedGeneration : observedGeneration ,
396- }
397- }
398-
399321// isBundleDepStale returns true if conditions are out of date.
400322func isBundleDepStale (bd * rukpakv1alpha1.BundleDeployment ) bool {
401323 return bd != nil && bd .Status .ObservedGeneration != bd .GetGeneration ()
0 commit comments