Skip to content

Commit 7bdb130

Browse files
abaysClaude (Anthropic)
andcommitted
[OSPRH-20357] Improve consistency of condition severity usage
Use consistent condition severity across repeated patterns found in our operators, and otherwise use an appropriate severity for conditions unique to each operator. Jira: https://issues.redhat.com/browse/OSPRH-20357 Co-authored-by: Claude (Anthropic) <[email protected]>
1 parent e1bf4aa commit 7bdb130

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

controllers/galera_controller.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,12 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
578578
time.Duration(5)*time.Second)
579579
if err != nil {
580580
if k8s_errors.IsNotFound(err) {
581+
// Since the OpenStack secret should have been manually created by the user and referenced in the spec,
582+
// we treat this as a warning because it means that the service will not be able to start.
581583
instance.Status.Conditions.Set(condition.FalseCondition(
582584
condition.InputReadyCondition,
583-
condition.RequestedReason,
584-
condition.SeverityInfo,
585+
condition.ErrorReason,
586+
condition.SeverityWarning,
585587
condition.InputReadyWaitingMessage))
586588
return res, fmt.Errorf("%w: %s", ErrOpenStackSecretNotFound, instance.Spec.Secret)
587589
}
@@ -610,10 +612,12 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
610612
)
611613
if err != nil {
612614
if k8s_errors.IsNotFound(err) {
615+
// Since the CA bundle secret should have been manually created by the user and provided in the spec,
616+
// we treat this as a warning because it means that the service will not be able to start.
613617
instance.Status.Conditions.Set(condition.FalseCondition(
614618
condition.TLSInputReadyCondition,
615-
condition.RequestedReason,
616-
condition.SeverityInfo,
619+
condition.ErrorReason,
620+
condition.SeverityWarning,
617621
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
618622
return ctrl.Result{}, nil
619623
}

controllers/galerabackup_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,11 @@ func (r *GaleraBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request
235235
if err != nil {
236236
if k8s_errors.IsNotFound(err) {
237237
// Wait for a Galera object to exist before creating any object (cronjob, PVs...)
238+
// Since the Galera object should already exist, we treat this as a warning.
238239
instance.Status.Conditions.MarkFalse(
239240
mariadbv1.MariaDBResourceExistsCondition,
240241
mariadbv1.ReasonResourceNotFound,
241-
condition.SeverityInfo,
242+
condition.SeverityWarning,
242243
mariadbv1.MariaDBResourceInitMessage,
243244
)
244245
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
@@ -316,8 +317,8 @@ func (r *GaleraBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request
316317
helper.GetLogger().Error(err, "CreateOrPatch failed", "pod", backupCronJob.Name)
317318
instance.Status.Conditions.MarkFalse(
318319
mariadbv1.CronjobReadyCondition,
319-
condition.ReadyReason,
320-
condition.SeverityInfo,
320+
condition.ErrorReason,
321+
condition.SeverityWarning,
321322
mariadbv1.CronjobReadyErrorMessage,
322323
err,
323324
)

controllers/mariadbaccount_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ func (r *MariaDBAccountReconciler) reconcileCreate(
160160
if err != nil && k8s_errors.IsNotFound(err) {
161161
// for the create case, need to wait for the MariaDBDatabase to exists before we can continue;
162162
// requeue
163+
// Since the MariaDBDatabase object should already exist, we treat this as a warning.
163164

164165
instance.Status.Conditions.Set(condition.FalseCondition(
165166
databasev1beta1.MariaDBDatabaseReadyCondition,
166167
databasev1beta1.ReasonDBNotFound,
167-
condition.SeverityInfo,
168+
condition.SeverityWarning,
168169
databasev1beta1.MariaDBDatabaseReadyInitMessage))
169170

170171
log.Info(fmt.Sprintf(
@@ -275,11 +276,12 @@ func (r *MariaDBAccountReconciler) reconcileCreate(
275276
time.Duration(30)*time.Second,
276277
)
277278
if (err != nil || secretResult != ctrl.Result{}) {
278-
279+
// Since the account secret should have been manually created by the user and referenced in the spec,
280+
// we treat this as a warning because it means that the service will not be able to start.
279281
instance.Status.Conditions.Set(condition.FalseCondition(
280282
databasev1beta1.MariaDBAccountReadyCondition,
281283
secret.ReasonSecretMissing,
282-
condition.SeverityInfo,
284+
condition.SeverityWarning,
283285
databasev1beta1.MariaDBAccountSecretNotReadyMessage, err))
284286

285287
return secretResult, err

tests/chainsaw/tests/account/account-missing-secret-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ status:
99
conditions:
1010
# message: 'MariaDBAccount secret is missing or incomplete: Secret $NAMESPACE/some-db-secret not found'
1111
- reason: SecretMissing
12-
severity: Info
12+
severity: Warning
1313
status: "False"
1414
type: Ready
1515
# message: 'MariaDBAccount secret is missing or incomplete: Secret $NAMESPACE/some-db-secret not found'
1616
- reason: SecretMissing
17-
severity: Info
17+
severity: Warning
1818
status: "False"
1919
type: MariaDBAccountReady
2020
- message: MariaDBDatabase ready

tests/kuttl/tests/account_create/03-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ status:
99
conditions:
1010
# message: 'MariaDBAccount secret is missing or incomplete: Secret $NAMESPACE/some-db-secret not found'
1111
- reason: SecretMissing
12-
severity: Info
12+
severity: Warning
1313
status: "False"
1414
type: Ready
1515
# message: 'MariaDBAccount secret is missing or incomplete: Secret $NAMESPACE/some-db-secret not found'
1616
- reason: SecretMissing
17-
severity: Info
17+
severity: Warning
1818
status: "False"
1919
type: MariaDBAccountReady
2020
- message: MariaDBDatabase ready

0 commit comments

Comments
 (0)