Skip to content

Commit a7ca1d5

Browse files
Merge pull request #529 from abays/OSPRH-20406
[OSPRH-20406] Improve consistency of condition severity usage
2 parents 29320fa + 9a26802 commit a7ca1d5

File tree

4 files changed

+58
-26
lines changed

4 files changed

+58
-26
lines changed

controllers/amphoracontroller_controller.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context
261261
nad, err := nad.GetNADWithName(ctx, helper, networkAttachment, instance.Namespace)
262262
if err != nil {
263263
if k8s_errors.IsNotFound(err) {
264+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
265+
// we treat this as a warning because it means that the service will not be able to start.
264266
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", networkAttachment))
265267
instance.Status.Conditions.Set(condition.FalseCondition(
266268
condition.NetworkAttachmentsReadyCondition,
267-
condition.RequestedReason,
268-
condition.SeverityInfo,
269+
condition.ErrorReason,
270+
condition.SeverityWarning,
269271
condition.NetworkAttachmentsReadyWaitingMessage,
270272
networkAttachment))
271273
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
@@ -321,10 +323,12 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context
321323
)
322324
if err != nil {
323325
if k8s_errors.IsNotFound(err) {
326+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
327+
// we treat this as a warning because it means that the service will not be able to start.
324328
instance.Status.Conditions.Set(condition.FalseCondition(
325329
condition.TLSInputReadyCondition,
326-
condition.RequestedReason,
327-
condition.SeverityInfo,
330+
condition.ErrorReason,
331+
condition.SeverityWarning,
328332
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
329333
return ctrl.Result{}, nil
330334
}
@@ -519,11 +523,13 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceSecrets(
519523
ospSecret, _, err := oko_secret.GetSecret(ctx, helper, instance.Spec.Secret, instance.Namespace)
520524
if err != nil {
521525
if k8s_errors.IsNotFound(err) {
526+
// Since the OpenStack secret should have been manually created by the user and referenced in the spec,
527+
// we treat this as a warning because it means that the service will not be able to start.
522528
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
523529
instance.Status.Conditions.Set(condition.FalseCondition(
524530
condition.InputReadyCondition,
525-
condition.RequestedReason,
526-
condition.SeverityInfo,
531+
condition.ErrorReason,
532+
condition.SeverityWarning,
527533
condition.InputReadyWaitingMessage))
528534
return err
529535
}
@@ -540,11 +546,14 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceSecrets(
540546
transportURLSecret, _, err := oko_secret.GetSecret(ctx, helper, instance.Spec.TransportURLSecret, instance.Namespace)
541547
if err != nil {
542548
if k8s_errors.IsNotFound(err) {
549+
// Since the TransportURL secret should have been automatically created by the parent Octavia CR
550+
// and referenced in the spec, we treat this as a warning because it means that the service will
551+
// not be able to start.
543552
Log.Info(fmt.Sprintf("TransportURL secret %s not found", instance.Spec.TransportURLSecret))
544553
instance.Status.Conditions.Set(condition.FalseCondition(
545554
condition.InputReadyCondition,
546-
condition.RequestedReason,
547-
condition.SeverityInfo,
555+
condition.ErrorReason,
556+
condition.SeverityWarning,
548557
condition.InputReadyWaitingMessage))
549558
return err
550559
}
@@ -642,10 +651,12 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceSecrets(
642651
ctx, helper, serverCAPassSecretName, instance.Namespace)
643652
if err != nil {
644653
if k8s_errors.IsNotFound(err) {
654+
// Since the CA passphrase secret should have been manually created by the user and referenced in the spec,
655+
// we treat this as a warning because it means that the service will not be able to start.
645656
instance.Status.Conditions.Set(condition.FalseCondition(
646657
condition.InputReadyCondition,
647-
condition.RequestedReason,
648-
condition.SeverityInfo,
658+
condition.ErrorReason,
659+
condition.SeverityWarning,
649660
condition.InputReadyWaitingMessage))
650661
return fmt.Errorf("%w: %s", octavia.ErrOpenstackServerCAPassphraseNotFound, serverCAPassSecretName)
651662
}

controllers/octavia_controller.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,13 @@ func (r *OctaviaReconciler) reconcileInit(
343343

344344
if err != nil {
345345
if k8s_errors.IsNotFound(err) {
346+
// Since the OpenStack secret should have been manually created by the user and referenced in the spec,
347+
// we treat this as a warning because it means that the service will not be able to start.
346348
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
347349
instance.Status.Conditions.Set(condition.FalseCondition(
348350
condition.InputReadyCondition,
349-
condition.RequestedReason,
350-
condition.SeverityInfo,
351+
condition.ErrorReason,
352+
condition.SeverityWarning,
351353
condition.InputReadyWaitingMessage))
352354
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
353355
}
@@ -359,10 +361,14 @@ func (r *OctaviaReconciler) reconcileInit(
359361
err.Error()))
360362
return ctrl.Result{}, err
361363
} else if (result != ctrl.Result{}) {
364+
// We can only get here if the secret is not found, thus we treat this the same
365+
// as we do above if there was an actual "not found" error returned.
366+
// See https://github.com/openstack-k8s-operators/lib-common/blob/4c240245107747327c5f67256f8d9d76cdd25c7a/modules/common/secret/secret.go#L423-L428
367+
// for further details.
362368
instance.Status.Conditions.Set(condition.FalseCondition(
363369
condition.InputReadyCondition,
364-
condition.RequestedReason,
365-
condition.SeverityInfo,
370+
condition.ErrorReason,
371+
condition.SeverityWarning,
366372
condition.InputReadyWaitingMessage))
367373
return result, err
368374
}
@@ -377,6 +383,8 @@ func (r *OctaviaReconciler) reconcileInit(
377383
)
378384
if err != nil {
379385
if k8s_errors.IsNotFound(err) {
386+
// Since the TransportURL secret is automatically created by this controller earlier in
387+
// the reconcile loop, we treat this as an info.
380388
Log.Info(fmt.Sprintf("TransportURL secret %s not found", instance.Status.TransportURLSecret))
381389
instance.Status.Conditions.Set(condition.FalseCondition(
382390
condition.InputReadyCondition,
@@ -619,11 +627,13 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
619627
nad, err := nad.GetNADWithName(ctx, helper, networkAttachment, instance.Namespace)
620628
if err != nil {
621629
if k8s_errors.IsNotFound(err) {
630+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
631+
// we treat this as a warning because it means that the service will not be able to start.
622632
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", networkAttachment))
623633
instance.Status.Conditions.Set(condition.FalseCondition(
624634
condition.NetworkAttachmentsReadyCondition,
625-
condition.RequestedReason,
626-
condition.SeverityInfo,
635+
condition.ErrorReason,
636+
condition.SeverityWarning,
627637
condition.NetworkAttachmentsReadyWaitingMessage,
628638
networkAttachment))
629639
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

controllers/octaviaapi_controller.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,12 @@ func (r *OctaviaAPIReconciler) reconcileNormal(ctx context.Context, instance *oc
665665
)
666666
if err != nil {
667667
if k8s_errors.IsNotFound(err) {
668+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
669+
// we treat this as a warning because it means that the service will not be able to start.
668670
instance.Status.Conditions.Set(condition.FalseCondition(
669671
condition.TLSInputReadyCondition,
670-
condition.RequestedReason,
671-
condition.SeverityInfo,
672+
condition.ErrorReason,
673+
condition.SeverityWarning,
672674
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
673675
return ctrl.Result{}, nil
674676
}
@@ -752,11 +754,13 @@ func (r *OctaviaAPIReconciler) reconcileNormal(ctx context.Context, instance *oc
752754
nad, err := nad.GetNADWithName(ctx, helper, networkAttachment, instance.Namespace)
753755
if err != nil {
754756
if k8s_errors.IsNotFound(err) {
757+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
758+
// we treat this as a warning because it means that the service will not be able to start.
755759
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", networkAttachment))
756760
instance.Status.Conditions.Set(condition.FalseCondition(
757761
condition.NetworkAttachmentsReadyCondition,
758-
condition.RequestedReason,
759-
condition.SeverityInfo,
762+
condition.ErrorReason,
763+
condition.SeverityWarning,
760764
condition.NetworkAttachmentsReadyWaitingMessage,
761765
networkAttachment))
762766
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
@@ -958,11 +962,13 @@ func (r *OctaviaAPIReconciler) generateServiceSecrets(
958962
ospSecret, _, err := oko_secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace)
959963
if err != nil {
960964
if k8s_errors.IsNotFound(err) {
965+
// Since the OpenStack secret should have been manually created by the user and referenced in the spec,
966+
// we treat this as a warning because it means that the service will not be able to start.
961967
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
962968
instance.Status.Conditions.Set(condition.FalseCondition(
963969
condition.InputReadyCondition,
964-
condition.RequestedReason,
965-
condition.SeverityInfo,
970+
condition.ErrorReason,
971+
condition.SeverityWarning,
966972
condition.InputReadyWaitingMessage))
967973
return err
968974
}
@@ -979,11 +985,14 @@ func (r *OctaviaAPIReconciler) generateServiceSecrets(
979985
transportURLSecret, _, err := oko_secret.GetSecret(ctx, h, instance.Spec.TransportURLSecret, instance.Namespace)
980986
if err != nil {
981987
if k8s_errors.IsNotFound(err) {
988+
// Since the TransportURL secret should have been automatically created by the parent Octavia CR
989+
// and referenced in the spec, we treat this as a warning because it means that the service will
990+
// not be able to start.
982991
Log.Info(fmt.Sprintf("TransportURL secret %s not found", instance.Spec.TransportURLSecret))
983992
instance.Status.Conditions.Set(condition.FalseCondition(
984993
condition.InputReadyCondition,
985-
condition.RequestedReason,
986-
condition.SeverityInfo,
994+
condition.ErrorReason,
995+
condition.SeverityWarning,
987996
condition.InputReadyWaitingMessage))
988997
return err
989998
}

controllers/octaviarsyslog_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@ func (r *OctaviaRsyslogReconciler) reconcileNormal(ctx context.Context, instance
238238
nad, err := nad.GetNADWithName(ctx, helper, networkAttachment, instance.Namespace)
239239
if err != nil {
240240
if k8s_errors.IsNotFound(err) {
241+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
242+
// we treat this as a warning because it means that the service will not be able to start.
241243
Log.Info(fmt.Sprintf("network-attachment-definition %s not found", networkAttachment))
242244
instance.Status.Conditions.Set(condition.FalseCondition(
243245
condition.NetworkAttachmentsReadyCondition,
244-
condition.RequestedReason,
245-
condition.SeverityInfo,
246+
condition.ErrorReason,
247+
condition.SeverityWarning,
246248
condition.NetworkAttachmentsReadyWaitingMessage,
247249
networkAttachment))
248250
return ctrl.Result{RequeueAfter: time.Second * 10}, nil

0 commit comments

Comments
 (0)