Skip to content

Commit abaedfb

Browse files
Merge pull request #287 from abays/OSPRH-19982
[OSPRH-19982] Improve consistency of condition severity usage
2 parents 94a5417 + f8ef378 commit abaedfb

4 files changed

Lines changed: 91 additions & 23 deletions

File tree

controllers/barbican_controller.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
251251
instance.Status.TransportURLSecret = transportURL.Status.SecretName
252252

253253
if instance.Status.TransportURLSecret == "" {
254+
// Since the TransportURL secret is automatically created by the Infra operator,
255+
// we treat this as an info (because the user is not responsible for manually creating it).
254256
Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name))
255257
instance.Status.Conditions.Set(condition.FalseCondition(
256258
barbicanv1beta1.BarbicanRabbitMQTransportURLReadyCondition,
@@ -328,11 +330,13 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
328330
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
329331
if err != nil {
330332
if k8s_errors.IsNotFound(err) {
333+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
334+
// we treat this as a warning because it means that the service will not be able to start.
331335
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
332336
instance.Status.Conditions.Set(condition.FalseCondition(
333337
condition.NetworkAttachmentsReadyCondition,
334-
condition.RequestedReason,
335-
condition.SeverityInfo,
338+
condition.ErrorReason,
339+
condition.SeverityWarning,
336340
condition.NetworkAttachmentsReadyWaitingMessage,
337341
netAtt))
338342
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
@@ -351,7 +355,6 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
351355
}
352356
}
353357

354-
// TODO: _ should be serviceAnnotations
355358
serviceAnnotations, err := nad.EnsureNetworksAnnotation(nadList)
356359
if err != nil {
357360
return ctrl.Result{}, fmt.Errorf("failed create network annotation from %s: %w",
@@ -1135,11 +1138,13 @@ func (r *BarbicanReconciler) verifySecret(
11351138
err.Error()))
11361139
return ctrl.Result{}, err
11371140
} else if (result != ctrl.Result{}) {
1141+
// We treat this as a warning because it means that the service will not be able to start
1142+
// while we are waiting for the secret to be created manually by the user.
11381143
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
11391144
instance.Status.Conditions.Set(condition.FalseCondition(
11401145
condition.InputReadyCondition,
1141-
condition.RequestedReason,
1142-
condition.SeverityInfo,
1146+
condition.ErrorReason,
1147+
condition.SeverityWarning,
11431148
condition.InputReadyWaitingMessage))
11441149
return result, nil
11451150
}

controllers/barbicanapi_controller.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,27 @@ func (r *BarbicanAPIReconciler) verifySecret(
225225
err.Error()))
226226
return ctrl.Result{}, err
227227
} else if (result != ctrl.Result{}) {
228+
// This function is used in different contexts, but only one of them, for the transport URL secret,
229+
// involves a secret that is automatically created elsewhere. For the other contexts, we treat this
230+
// as a warning because it means that the service will not be able to start while we are waiting for
231+
// the secret to be created manually by the user.
232+
233+
var reason condition.Reason
234+
var severity condition.Severity
235+
236+
if expectedFields != nil && slices.Contains(expectedFields, TransportURL) {
237+
reason = condition.RequestedReason
238+
severity = condition.SeverityInfo
239+
} else {
240+
reason = condition.ErrorReason
241+
severity = condition.SeverityWarning
242+
}
243+
228244
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
229245
instance.Status.Conditions.Set(condition.FalseCondition(
230246
condition.InputReadyCondition,
231-
condition.RequestedReason,
232-
condition.SeverityInfo,
247+
reason,
248+
severity,
233249
condition.InputReadyWaitingMessage))
234250
return result, nil
235251
}
@@ -632,10 +648,12 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
632648
)
633649
if err != nil {
634650
if k8s_errors.IsNotFound(err) {
651+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
652+
// we treat this as a warning because it means that the service will not be able to start.
635653
instance.Status.Conditions.Set(condition.FalseCondition(
636654
condition.TLSInputReadyCondition,
637-
condition.RequestedReason,
638-
condition.SeverityInfo,
655+
condition.ErrorReason,
656+
condition.SeverityWarning,
639657
condition.TLSInputReadyWaitingMessage,
640658
instance.Spec.TLS.CaBundleSecretName))
641659
return ctrl.Result{}, nil
@@ -659,6 +677,8 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
659677
certsHash, err := instance.Spec.TLS.API.ValidateCertSecrets(ctx, helper, instance.Namespace)
660678
if err != nil {
661679
if k8s_errors.IsNotFound(err) {
680+
// Since the OpenStackControlPlane creates the API service certs secrets,
681+
// we treat this as an info (because the user is not responsible for manually creating them).
662682
instance.Status.Conditions.Set(condition.FalseCondition(
663683
condition.TLSInputReadyCondition,
664684
condition.RequestedReason,
@@ -710,11 +730,13 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
710730
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
711731
if err != nil {
712732
if k8s_errors.IsNotFound(err) {
733+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
734+
// we treat this as a warning because it means that the service will not be able to start.
713735
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
714736
instance.Status.Conditions.Set(condition.FalseCondition(
715737
condition.NetworkAttachmentsReadyCondition,
716-
condition.RequestedReason,
717-
condition.SeverityInfo,
738+
condition.ErrorReason,
739+
condition.SeverityWarning,
718740
condition.NetworkAttachmentsReadyWaitingMessage,
719741
netAtt))
720742
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

controllers/barbicankeystonelistener_controller.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22+
"slices"
2223
"time"
2324

2425
"github.com/go-logr/logr"
@@ -203,11 +204,27 @@ func (r *BarbicanKeystoneListenerReconciler) verifySecret(
203204
err.Error()))
204205
return ctrl.Result{}, err
205206
} else if (result != ctrl.Result{}) {
207+
// This function is used in different contexts, but only one of them, for the transport URL secret,
208+
// involves a secret that is automatically created elsewhere. For the other contexts, we treat this
209+
// as a warning because it means that the service will not be able to start while we are waiting for
210+
// the secret to be created manually by the user.
211+
212+
var reason condition.Reason
213+
var severity condition.Severity
214+
215+
if expectedFields != nil && slices.Contains(expectedFields, TransportURL) {
216+
reason = condition.RequestedReason
217+
severity = condition.SeverityInfo
218+
} else {
219+
reason = condition.ErrorReason
220+
severity = condition.SeverityWarning
221+
}
222+
206223
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
207224
instance.Status.Conditions.Set(condition.FalseCondition(
208225
condition.InputReadyCondition,
209-
condition.RequestedReason,
210-
condition.SeverityInfo,
226+
reason,
227+
severity,
211228
condition.InputReadyWaitingMessage))
212229
return result, nil
213230
}
@@ -421,10 +438,12 @@ func (r *BarbicanKeystoneListenerReconciler) reconcileNormal(ctx context.Context
421438
)
422439
if err != nil {
423440
if k8s_errors.IsNotFound(err) {
441+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
442+
// we treat this as a warning because it means that the service will not be able to start.
424443
instance.Status.Conditions.Set(condition.FalseCondition(
425444
condition.TLSInputReadyCondition,
426-
condition.RequestedReason,
427-
condition.SeverityInfo,
445+
condition.ErrorReason,
446+
condition.SeverityWarning,
428447
condition.TLSInputReadyWaitingMessage,
429448
instance.Spec.TLS.CaBundleSecretName))
430449
return ctrl.Result{}, nil
@@ -497,11 +516,13 @@ func (r *BarbicanKeystoneListenerReconciler) reconcileNormal(ctx context.Context
497516
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
498517
if err != nil {
499518
if k8s_errors.IsNotFound(err) {
519+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
520+
// we treat this as a warning because it means that the service will not be able to start.
500521
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
501522
instance.Status.Conditions.Set(condition.FalseCondition(
502523
condition.NetworkAttachmentsReadyCondition,
503-
condition.RequestedReason,
504-
condition.SeverityInfo,
524+
condition.ErrorReason,
525+
condition.SeverityWarning,
505526
condition.NetworkAttachmentsReadyWaitingMessage,
506527
netAtt))
507528
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

controllers/barbicanworker_controller.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,27 @@ func (r *BarbicanWorkerReconciler) verifySecret(
195195
err.Error()))
196196
return ctrl.Result{}, err
197197
} else if (result != ctrl.Result{}) {
198+
// This function is used in different contexts, but only one of them, for the transport URL secret,
199+
// involves a secret that is automatically created elsewhere. For the other contexts, we treat this
200+
// as a warning because it means that the service will not be able to start while we are waiting for
201+
// the secret to be created manually by the user.
202+
203+
var reason condition.Reason
204+
var severity condition.Severity
205+
206+
if expectedFields != nil && slices.Contains(expectedFields, TransportURL) {
207+
reason = condition.RequestedReason
208+
severity = condition.SeverityInfo
209+
} else {
210+
reason = condition.ErrorReason
211+
severity = condition.SeverityWarning
212+
}
213+
198214
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
199215
instance.Status.Conditions.Set(condition.FalseCondition(
200216
condition.InputReadyCondition,
201-
condition.RequestedReason,
202-
condition.SeverityInfo,
217+
reason,
218+
severity,
203219
condition.InputReadyWaitingMessage))
204220
return result, nil
205221
}
@@ -419,10 +435,12 @@ func (r *BarbicanWorkerReconciler) reconcileNormal(ctx context.Context, instance
419435
)
420436
if err != nil {
421437
if k8s_errors.IsNotFound(err) {
438+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
439+
// we treat this as a warning because it means that the service will not be able to start.
422440
instance.Status.Conditions.Set(condition.FalseCondition(
423441
condition.TLSInputReadyCondition,
424-
condition.RequestedReason,
425-
condition.SeverityInfo,
442+
condition.ErrorReason,
443+
condition.SeverityWarning,
426444
condition.TLSInputReadyWaitingMessage,
427445
instance.Spec.TLS.CaBundleSecretName))
428446
return ctrl.Result{}, nil
@@ -495,11 +513,13 @@ func (r *BarbicanWorkerReconciler) reconcileNormal(ctx context.Context, instance
495513
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
496514
if err != nil {
497515
if k8s_errors.IsNotFound(err) {
516+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
517+
// we treat this as a warning because it means that the service will not be able to start.
498518
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
499519
instance.Status.Conditions.Set(condition.FalseCondition(
500520
condition.NetworkAttachmentsReadyCondition,
501-
condition.RequestedReason,
502-
condition.SeverityInfo,
521+
condition.ErrorReason,
522+
condition.SeverityWarning,
503523
condition.NetworkAttachmentsReadyWaitingMessage,
504524
netAtt))
505525
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

0 commit comments

Comments
 (0)