Skip to content

Commit 4ea83e6

Browse files
jmprusitmshort
authored andcommitted
Implements logic for new status cond. and fields
Signed-off-by: Joaquim Moreno Prusi <[email protected]>
1 parent bfb8716 commit 4ea83e6

File tree

3 files changed

+212
-6
lines changed

3 files changed

+212
-6
lines changed

controllers/operator_controller.go

+44
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
113113
Message: err.Error(),
114114
ObservedGeneration: op.GetGeneration(),
115115
})
116+
// Set the TypeResolved condition to Unknown to indicate that the resolution
117+
// hasn't been attempted yet, due to the spec being invalid.
118+
op.Status.ResolvedBundleResource = ""
119+
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
120+
Type: operatorsv1alpha1.TypeResolved,
121+
Status: metav1.ConditionUnknown,
122+
Reason: operatorsv1alpha1.ReasonResolutionUnknown,
123+
Message: "validation has not been attempted as spec is invalid",
124+
ObservedGeneration: op.GetGeneration(),
125+
})
116126
return ctrl.Result{}, nil
117127
}
118128
// run resolution
@@ -125,6 +135,14 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
125135
Message: err.Error(),
126136
ObservedGeneration: op.GetGeneration(),
127137
})
138+
op.Status.ResolvedBundleResource = ""
139+
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
140+
Type: operatorsv1alpha1.TypeResolved,
141+
Status: metav1.ConditionFalse,
142+
Reason: operatorsv1alpha1.ReasonResolutionFailed,
143+
Message: err.Error(),
144+
ObservedGeneration: op.GetGeneration(),
145+
})
128146
return ctrl.Result{}, err
129147
}
130148

@@ -139,6 +157,14 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
139157
Message: err.Error(),
140158
ObservedGeneration: op.GetGeneration(),
141159
})
160+
op.Status.ResolvedBundleResource = ""
161+
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
162+
Type: operatorsv1alpha1.TypeResolved,
163+
Status: metav1.ConditionFalse,
164+
Reason: operatorsv1alpha1.ReasonResolutionFailed,
165+
Message: err.Error(),
166+
ObservedGeneration: op.GetGeneration(),
167+
})
142168
return ctrl.Result{}, err
143169
}
144170

@@ -152,9 +178,27 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
152178
Message: err.Error(),
153179
ObservedGeneration: op.GetGeneration(),
154180
})
181+
op.Status.ResolvedBundleResource = ""
182+
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
183+
Type: operatorsv1alpha1.TypeResolved,
184+
Status: metav1.ConditionFalse,
185+
Reason: operatorsv1alpha1.ReasonResolutionFailed,
186+
Message: err.Error(),
187+
ObservedGeneration: op.GetGeneration(),
188+
})
155189
return ctrl.Result{}, err
156190
}
157191

192+
// Now we can set the Resolved Condition, and the resolvedBundleSource field to the bundleImage value.
193+
op.Status.ResolvedBundleResource = bundleImage
194+
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
195+
Type: operatorsv1alpha1.TypeResolved,
196+
Status: metav1.ConditionTrue,
197+
Reason: operatorsv1alpha1.ReasonSuccess,
198+
Message: fmt.Sprintf("resolved to %q", bundleImage),
199+
ObservedGeneration: op.GetGeneration(),
200+
})
201+
158202
// Ensure a BundleDeployment exists with its bundle source from the bundle
159203
// image we just looked up in the solution.
160204
dep := r.generateExpectedBundleDeployment(*op, bundleImage)

0 commit comments

Comments
 (0)