Skip to content

Commit c96fef5

Browse files
Modify Operator Conditions (#130)
This PR brings in 2 changes: 1. Introduce a new reason for Unknown status: Currently, we specify BundleDeploymentFailure or InstallationSuccess as reasons for an unknown status. This means that we are not sure if the install is successfull or we aren't sure of a failure either. To make it more accurate, we introduce a new reason "InstallStatusUnknown" to mean that the status cannot be determined at that particular instant. 2. Rename "BundleDeploymentFailed" to "InstallationUnsuccessful" This prevents leaking of Rukpak API names. BundleDeployment Failed can be one of the reason for unsuccessful installation. Signed-off-by: Varsha Prasad Narsing <[email protected]>
1 parent 88392cb commit c96fef5

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

api/v1alpha1/operator_types.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ const (
3333
// TODO(user): add more Types, here and into init()
3434
TypeReady = "Ready"
3535

36-
ReasonInstallationSucceeded = "InstallationSucceeded"
37-
ReasonResolutionFailed = "ResolutionFailed"
38-
ReasonBundleLookupFailed = "BundleLookupFailed"
39-
ReasonBundleDeploymentFailed = "BundleDeploymentFailed"
36+
ReasonInstallationSucceeded = "InstallationSucceeded"
37+
ReasonResolutionFailed = "ResolutionFailed"
38+
ReasonBundleLookupFailed = "BundleLookupFailed"
39+
ReasonInstallationFailed = "InstallationFailed"
40+
ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
4041
)
4142

4243
func init() {
@@ -49,7 +50,8 @@ func init() {
4950
ReasonInstallationSucceeded,
5051
ReasonResolutionFailed,
5152
ReasonBundleLookupFailed,
52-
ReasonBundleDeploymentFailed,
53+
ReasonInstallationFailed,
54+
ReasonInstallationStatusUnknown,
5355
)
5456
}
5557

controllers/operator_controller.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
155155
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
156156
Type: operatorsv1alpha1.TypeReady,
157157
Status: metav1.ConditionFalse,
158-
Reason: operatorsv1alpha1.ReasonBundleDeploymentFailed,
158+
Reason: operatorsv1alpha1.ReasonInstallationFailed,
159159
Message: err.Error(),
160160
ObservedGeneration: op.GetGeneration(),
161161
})
@@ -168,7 +168,7 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
168168
apimeta.SetStatusCondition(&op.Status.Conditions, metav1.Condition{
169169
Type: operatorsv1alpha1.TypeReady,
170170
Status: metav1.ConditionUnknown,
171-
Reason: operatorsv1alpha1.ReasonInstallationSucceeded,
171+
Reason: operatorsv1alpha1.ReasonInstallationStatusUnknown,
172172
Message: err.Error(),
173173
ObservedGeneration: op.GetGeneration(),
174174
})
@@ -320,11 +320,14 @@ func mapBDStatusToReadyCondition(existingBD *rukpakv1alpha1.BundleDeployment, ob
320320
// 3. If the Operator "Ready" status is "False": There is error observed from Rukpak. Update the status accordingly.
321321
status, message := verifyBDStatus(existingBD)
322322
var reason string
323-
// TODO: introduce a new reason for condition Unknown, instead of defaulting it to Installation Succeeded.
324-
if status == metav1.ConditionTrue {
323+
324+
switch status {
325+
case metav1.ConditionTrue:
325326
reason = operatorsv1alpha1.ReasonInstallationSucceeded
326-
} else {
327-
reason = operatorsv1alpha1.ReasonBundleDeploymentFailed
327+
case metav1.ConditionFalse:
328+
reason = operatorsv1alpha1.ReasonInstallationFailed
329+
default:
330+
reason = operatorsv1alpha1.ReasonInstallationStatusUnknown
328331
}
329332

330333
return metav1.Condition{

controllers/operator_controller_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ var _ = Describe("Reconcile Test", func() {
116116
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady)
117117
Expect(cond).NotTo(BeNil())
118118
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
119-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
119+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
120120
Expect(cond.Message).To(ContainSubstring("waiting for bundleDeployment"))
121121
})
122122
})
@@ -179,7 +179,7 @@ var _ = Describe("Reconcile Test", func() {
179179
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady)
180180
Expect(cond).NotTo(BeNil())
181181
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
182-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
182+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
183183
Expect(cond.Message).To(ContainSubstring("waiting for bundleDeployment"))
184184
})
185185
})
@@ -227,7 +227,7 @@ var _ = Describe("Reconcile Test", func() {
227227
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady)
228228
Expect(cond).NotTo(BeNil())
229229
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
230-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
230+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
231231
Expect(cond.Message).To(ContainSubstring("waiting for bundleDeployment"))
232232
})
233233
})
@@ -363,7 +363,7 @@ var _ = Describe("Reconcile Test", func() {
363363
cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady)
364364
Expect(cond).NotTo(BeNil())
365365
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
366-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
366+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
367367
Expect(cond.Message).To(ContainSubstring(`waiting for bundleDeployment`))
368368
})
369369

@@ -393,7 +393,7 @@ var _ = Describe("Reconcile Test", func() {
393393
cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady)
394394
Expect(cond).NotTo(BeNil())
395395
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
396-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
396+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationFailed))
397397
Expect(cond.Message).To(ContainSubstring(`failed to unpack`))
398398
})
399399

@@ -423,7 +423,7 @@ var _ = Describe("Reconcile Test", func() {
423423
cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady)
424424
Expect(cond).NotTo(BeNil())
425425
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
426-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
426+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationFailed))
427427
Expect(cond.Message).To(ContainSubstring(`failed to install`))
428428
})
429429

@@ -490,7 +490,7 @@ var _ = Describe("Reconcile Test", func() {
490490
cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady)
491491
Expect(cond).NotTo(BeNil())
492492
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
493-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
493+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
494494
Expect(cond.Message).To(ContainSubstring(`could not determine the state of bundleDeployment`))
495495
})
496496

@@ -520,7 +520,7 @@ var _ = Describe("Reconcile Test", func() {
520520
cond := apimeta.FindStatusCondition(op.Status.Conditions, operatorsv1alpha1.TypeReady)
521521
Expect(cond).NotTo(BeNil())
522522
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
523-
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonBundleDeploymentFailed))
523+
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown))
524524
Expect(cond.Message).To(ContainSubstring(`could not determine the state of bundleDeployment`))
525525
})
526526
})

0 commit comments

Comments
 (0)