Skip to content

Commit df92da6

Browse files
Conditions: Map out-of-date bundleDeployment with an operator condition
This PR brings in the change that sets the operator condition to Unknown when the BundleDeployment's conditions are out od date. Signed-off-by: Varsha Prasad Narsing <[email protected]>
1 parent 07ae744 commit df92da6

File tree

2 files changed

+190
-149
lines changed

2 files changed

+190
-149
lines changed

controllers/operator_controller.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,6 @@ func verifyBDStatus(dep *rukpakv1alpha1.BundleDeployment) (metav1.ConditionStatu
294294
isValidBundleCond := apimeta.FindStatusCondition(dep.Status.Conditions, rukpakv1alpha1.TypeHasValidBundle)
295295
isInstalledCond := apimeta.FindStatusCondition(dep.Status.Conditions, rukpakv1alpha1.TypeInstalled)
296296

297-
if isValidBundleCond == nil && isInstalledCond == nil {
298-
return metav1.ConditionUnknown, fmt.Sprintf("waiting for bundleDeployment %q status to be updated", dep.Name)
299-
}
300-
301297
if isValidBundleCond != nil && isValidBundleCond.Status == metav1.ConditionFalse {
302298
return metav1.ConditionFalse, isValidBundleCond.Message
303299
}
@@ -309,11 +305,21 @@ func verifyBDStatus(dep *rukpakv1alpha1.BundleDeployment) (metav1.ConditionStatu
309305
if isInstalledCond != nil && isInstalledCond.Status == metav1.ConditionTrue {
310306
return metav1.ConditionTrue, "install was successful"
311307
}
312-
return metav1.ConditionUnknown, fmt.Sprintf("could not determine the state of bundleDeployment %s", dep.Name)
308+
return metav1.ConditionUnknown, fmt.Sprintf("could not determine the state of BundleDeployment %s", dep.Name)
313309
}
314310

315311
// mapBDStatusToReadyCondition returns the operator object's "TypeReady" condition based on the bundle deployment statuses.
316312
func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, observedGeneration int64) metav1.Condition {
313+
// if BundleDeployment status is stale, return an unknown condition.
314+
if isBundleDepStale(existingBD) {
315+
return metav1.Condition{
316+
Type: operatorsv1alpha1.TypeReady,
317+
Status: metav1.ConditionUnknown,
318+
Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown,
319+
Message: fmt.Sprintf("waiting for BundleDeployment %q status to be updated. BundleDeployment conditions out of date.", existingBD.Name),
320+
ObservedGeneration: observedGeneration,
321+
}
322+
}
317323
// update operator status:
318324
// 1. If the Operator "Ready" status is "Unknown": The status of successful bundleDeployment is unknown, wait till Rukpak updates the BD status.
319325
// 2. If the Operator "Ready" status is "True": Update the "successful resolution" status and return the result.
@@ -338,3 +344,8 @@ func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, ob
338344
ObservedGeneration: observedGeneration,
339345
}
340346
}
347+
348+
// isBundleDepStale returns true if conditions are out of date.
349+
func isBundleDepStale(bd *rukpakv1alpha1.BundleDeployment) bool {
350+
return bd != nil && bd.Status.ObservedGeneration != bd.GetGeneration()
351+
}

0 commit comments

Comments
 (0)