@@ -106,13 +106,6 @@ func checkForUnexpectedFieldChange(a, b operatorsv1alpha1.Operator) bool {
106
106
func (r * OperatorReconciler ) reconcile (ctx context.Context , op * operatorsv1alpha1.Operator ) (ctrl.Result , error ) {
107
107
// validate spec
108
108
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
- })
116
109
// Set the TypeResolved condition to Unknown to indicate that the resolution
117
110
// hasn't been attempted yet, due to the spec being invalid.
118
111
op .Status .ResolvedBundleResource = ""
@@ -128,13 +121,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
128
121
// run resolution
129
122
solution , err := r .Resolver .Resolve (ctx )
130
123
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
- })
138
124
op .Status .ResolvedBundleResource = ""
139
125
apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
140
126
Type : operatorsv1alpha1 .TypeResolved ,
@@ -150,13 +136,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
150
136
// Operator's desired package name.
151
137
bundleEntity , err := r .getBundleEntityFromSolution (solution , op .Spec .PackageName )
152
138
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
- })
160
139
op .Status .ResolvedBundleResource = ""
161
140
apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
162
141
Type : operatorsv1alpha1 .TypeResolved ,
@@ -171,13 +150,6 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
171
150
// Get the bundle image reference for the bundle
172
151
bundleImage , err := bundleEntity .BundlePath ()
173
152
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
- })
181
153
op .Status .ResolvedBundleResource = ""
182
154
apimeta .SetStatusCondition (& op .Status .Conditions , metav1.Condition {
183
155
Type : operatorsv1alpha1 .TypeResolved ,
@@ -203,31 +175,18 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
203
175
// image we just looked up in the solution.
204
176
dep := r .generateExpectedBundleDeployment (* op , bundleImage )
205
177
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
213
179
return ctrl.Result {}, err
214
180
}
215
181
216
182
// convert existing unstructured object into bundleDeployment for easier mapping of status.
217
183
existingTypedBundleDeployment := & rukpakv1alpha1.BundleDeployment {}
218
184
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
226
186
return ctrl.Result {}, err
227
187
}
228
188
229
189
// set the status of the operator based on the respective bundle deployment status conditions.
230
- apimeta .SetStatusCondition (& op .Status .Conditions , mapBDStatusToReadyCondition (existingTypedBundleDeployment , op .GetGeneration ()))
231
190
return ctrl.Result {}, nil
232
191
}
233
192
@@ -359,43 +318,6 @@ func verifyBDStatus(dep *rukpakv1alpha1.BundleDeployment) (metav1.ConditionStatu
359
318
return metav1 .ConditionUnknown , fmt .Sprintf ("could not determine the state of BundleDeployment %s" , dep .Name )
360
319
}
361
320
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
-
399
321
// isBundleDepStale returns true if conditions are out of date.
400
322
func isBundleDepStale (bd * rukpakv1alpha1.BundleDeployment ) bool {
401
323
return bd != nil && bd .Status .ObservedGeneration != bd .GetGeneration ()
0 commit comments