Skip to content

Commit 0292864

Browse files
Merge pull request #393 from abays/OSPRH-20444
[OSPRH-20444] Improve consistency of condition severity usage
2 parents 69d91f6 + ce8eb0f commit 0292864

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

controllers/swift_common.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,13 @@ func verifyServiceSecret(
131131
err.Error()))
132132
return res, err
133133
} else if (res != ctrl.Result{}) {
134+
// Since the service secret should have been manually created by the user and referenced in the spec,
135+
// we treat this as a warning because it means that the service will not be able to start.
134136
log.FromContext(ctx).Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
135137
conditionUpdater.Set(condition.FalseCondition(
136138
condition.InputReadyCondition,
137-
condition.RequestedReason,
138-
condition.SeverityInfo,
139+
condition.ErrorReason,
140+
condition.SeverityWarning,
139141
condition.InputReadyWaitingMessage))
140142
return res, nil
141143
}

controllers/swift_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,15 @@ func (r *SwiftReconciler) reconcileNormal(ctx context.Context, instance *swiftv1
244244
memcached, err := memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace)
245245
if err != nil {
246246
if apierrors.IsNotFound(err) {
247+
// Memcached should be automatically created by the encompassing OpenStackControlPlane,
248+
// but we don't propagate its name into the "memcachedInstance" field of other sub-resources,
249+
// so if it is missing at this point, it *could* be because there's a mismatch between the
250+
// name of the Memcached CR and the name of the Memcached instance referenced by this CR.
251+
// Since that situation would block further reconciliation, we treat it as a warning.
247252
instance.Status.Conditions.Set(condition.FalseCondition(
248253
condition.MemcachedReadyCondition,
249-
condition.RequestedReason,
250-
condition.SeverityInfo,
254+
condition.ErrorReason,
255+
condition.SeverityWarning,
251256
condition.MemcachedReadyWaitingMessage))
252257
Log.Info(fmt.Sprintf("%s... requeueing", condition.MemcachedReadyWaitingMessage))
253258
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil

controllers/swiftproxy_controller.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,12 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
215215
)
216216
if err != nil {
217217
if apierrors.IsNotFound(err) {
218+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
219+
// we treat this as a warning because it means that the service will not be able to start.
218220
instance.Status.Conditions.Set(condition.FalseCondition(
219221
condition.TLSInputReadyCondition,
220-
condition.RequestedReason,
221-
condition.SeverityInfo,
222+
condition.ErrorReason,
223+
condition.SeverityWarning,
222224
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
223225
return ctrl.Result{}, nil
224226
}
@@ -522,10 +524,12 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
522524
secretRef, err = swiftproxy.GetBarbicanSecret(instance, helper, keystonePublicURL, password)
523525
if err != nil {
524526
if apierrors.IsNotFound(err) {
527+
// Since the Barbican secret is required for encryption, we treat this as a warning
528+
// because it means that the service will not be able to start.
525529
instance.Status.Conditions.Set(condition.FalseCondition(
526530
condition.InputReadyCondition,
527-
condition.RequestedReason,
528-
condition.SeverityInfo,
531+
condition.ErrorReason,
532+
condition.SeverityWarning,
529533
condition.InputReadyWaitingMessage))
530534
Log.Error(err, "Failed to get secretRef from Barbican")
531535
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
@@ -552,11 +556,16 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
552556
memcached, err := memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace)
553557
if err != nil {
554558
if apierrors.IsNotFound(err) {
559+
// Memcached should be automatically created by the encompassing OpenStackControlPlane,
560+
// but we don't propagate its name into the "memcachedInstance" field of other sub-resources,
561+
// so if it is missing at this point, it *could* be because there's a mismatch between the
562+
// name of the Memcached CR and the name of the Memcached instance referenced by this CR.
563+
// Since that situation would block further reconciliation, we treat it as a warning.
555564
Log.Info(fmt.Sprintf("memcached %s not found", instance.Spec.MemcachedInstance))
556565
instance.Status.Conditions.Set(condition.FalseCondition(
557566
condition.MemcachedReadyCondition,
558-
condition.RequestedReason,
559-
condition.SeverityInfo,
567+
condition.ErrorReason,
568+
condition.SeverityWarning,
560569
condition.MemcachedReadyWaitingMessage))
561570
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
562571
}
@@ -612,10 +621,12 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
612621
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
613622
if err != nil {
614623
if apierrors.IsNotFound(err) {
624+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
625+
// we treat this as a warning because it means that the service will not be able to start.
615626
instance.Status.Conditions.Set(condition.FalseCondition(
616627
condition.NetworkAttachmentsReadyCondition,
617-
condition.RequestedReason,
618-
condition.SeverityInfo,
628+
condition.ErrorReason,
629+
condition.SeverityWarning,
619630
condition.NetworkAttachmentsReadyWaitingMessage,
620631
netAtt))
621632
Log.Error(err, "network-attachment-definition not found")

controllers/swiftstorage_controller.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,16 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request
219219
memcached, err := memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace)
220220
if err != nil {
221221
if apierrors.IsNotFound(err) {
222+
// Memcached should be automatically created by the encompassing OpenStackControlPlane,
223+
// but we don't propagate its name into the "memcachedInstance" field of other sub-resources,
224+
// so if it is missing at this point, it *could* be because there's a mismatch between the
225+
// name of the Memcached CR and the name of the Memcached instance referenced by this CR.
226+
// Since that situation would block further reconciliation, we treat it as a warning.
222227
Log.Info(fmt.Sprintf("memcached %s not found", instance.Spec.MemcachedInstance))
223228
instance.Status.Conditions.Set(condition.FalseCondition(
224229
condition.MemcachedReadyCondition,
225-
condition.RequestedReason,
226-
condition.SeverityInfo,
230+
condition.ErrorReason,
231+
condition.SeverityWarning,
227232
condition.MemcachedReadyWaitingMessage))
228233
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
229234
}
@@ -262,10 +267,12 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request
262267
nad, err := networkattachment.GetNADWithName(ctx, helper, netAtt, instance.Namespace)
263268
if err != nil {
264269
if apierrors.IsNotFound(err) {
270+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
271+
// we treat this as a warning because it means that the service will not be able to start.
265272
instance.Status.Conditions.Set(condition.FalseCondition(
266273
condition.NetworkAttachmentsReadyCondition,
267-
condition.RequestedReason,
268-
condition.SeverityInfo,
274+
condition.ErrorReason,
275+
condition.SeverityWarning,
269276
condition.NetworkAttachmentsReadyWaitingMessage,
270277
netAtt))
271278
Log.Error(err, "network-attachment-definition not found")

0 commit comments

Comments
 (0)