Skip to content

Commit 092fa45

Browse files
Merge pull request #801 from abays/OSPRH-20189
[OSPRH-20189] Improve consistency of condition severity usage
2 parents b0f3757 + b467c0a commit 092fa45

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

controllers/glance_common.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ func verifyServiceSecret(
102102
err.Error()))
103103
return res, err
104104
} else if (res != ctrl.Result{}) {
105+
// Since the service secret should have been manually created by the user and referenced in the spec,
106+
// we treat this as a warning because it means that the service will not be able to start.
105107
log.FromContext(ctx).Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
106108
conditionUpdater.Set(condition.FalseCondition(
107109
condition.InputReadyCondition,
108-
condition.RequestedReason,
109-
condition.SeverityInfo,
110+
condition.ErrorReason,
111+
condition.SeverityWarning,
110112
condition.InputReadyWaitingMessage))
111113
return res, nil
112114
}
@@ -133,11 +135,13 @@ func ensureNAD(
133135
nad, err := nad.GetNADWithName(ctx, helper, netAtt, helper.GetBeforeObject().GetNamespace())
134136
if err != nil {
135137
if k8s_errors.IsNotFound(err) {
138+
// Since the net-attach-def CR should have been manually created by the user and referenced in the spec,
139+
// we treat this as a warning because it means that the service will not be able to start.
136140
helper.GetLogger().Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
137141
conditionUpdater.Set(condition.FalseCondition(
138142
condition.NetworkAttachmentsReadyCondition,
139-
condition.RequestedReason,
140-
condition.SeverityInfo,
143+
condition.ErrorReason,
144+
condition.SeverityWarning,
141145
condition.NetworkAttachmentsReadyWaitingMessage,
142146
netAtt))
143147
return serviceAnnotations, glance.ResultRequeue, nil

controllers/glance_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,13 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
623623
memcached, err = memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace)
624624
if err != nil {
625625
if k8s_errors.IsNotFound(err) {
626+
// Memcached should be automatically created by the encompassing OpenStackControlPlane,
627+
// but we don't propagate its name into the "memcachedInstance" field of other sub-resources,
628+
// so we treat this as a warning because it means that the service will not be able to start.
626629
instance.Status.Conditions.Set(condition.FalseCondition(
627630
condition.MemcachedReadyCondition,
628-
condition.RequestedReason,
629-
condition.SeverityInfo,
631+
condition.ErrorReason,
632+
condition.SeverityWarning,
630633
condition.MemcachedReadyWaitingMessage))
631634
Log.Info(fmt.Sprintf("%s...requeueing", condition.MemcachedReadyWaitingMessage))
632635
return glance.ResultRequeue, nil

controllers/glanceapi_controller.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (r *GlanceAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
169169
// failure
170170
condition.UnknownCondition(condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage),
171171
condition.UnknownCondition(glancev1.CinderCondition, condition.InitReason, glancev1.CinderInitMessage),
172+
condition.UnknownCondition(condition.MemcachedReadyCondition, condition.InitReason, condition.MemcachedReadyInitMessage),
172173
condition.UnknownCondition(condition.CreateServiceReadyCondition, condition.InitReason, condition.CreateServiceReadyInitMessage),
173174
condition.UnknownCondition(condition.InputReadyCondition, condition.InitReason, condition.InputReadyInitMessage),
174175
condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage),
@@ -714,11 +715,14 @@ func (r *GlanceAPIReconciler) reconcileNormal(
714715
memcached, err := memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace)
715716
if err != nil {
716717
if k8s_errors.IsNotFound(err) {
718+
// Memcached should be automatically created by the encompassing OpenStackControlPlane,
719+
// but we don't propagate its name into the "memcachedInstance" field of other sub-resources,
720+
// so we treat this as a warning because it means that the service will not be able to start.
717721
Log.Info(fmt.Sprintf("memcached %s not found", instance.Spec.MemcachedInstance))
718722
instance.Status.Conditions.Set(condition.FalseCondition(
719723
condition.MemcachedReadyCondition,
720-
condition.RequestedReason,
721-
condition.SeverityInfo,
724+
condition.ErrorReason,
725+
condition.SeverityWarning,
722726
condition.MemcachedReadyWaitingMessage))
723727
return glance.ResultRequeue, nil
724728
}
@@ -731,6 +735,20 @@ func (r *GlanceAPIReconciler) reconcileNormal(
731735
return ctrl.Result{}, err
732736
}
733737

738+
if !memcached.IsReady() {
739+
instance.Status.Conditions.Set(condition.FalseCondition(
740+
condition.MemcachedReadyCondition,
741+
condition.RequestedReason,
742+
condition.SeverityInfo,
743+
condition.MemcachedReadyWaitingMessage))
744+
Log.Info(fmt.Sprintf("%s...requeueing", condition.MemcachedReadyWaitingMessage))
745+
return glance.ResultRequeue, nil
746+
}
747+
// Mark the Memcached Service as Ready if we get to this point with no errors
748+
instance.Status.Conditions.MarkTrue(
749+
condition.MemcachedReadyCondition, condition.MemcachedReadyMessage)
750+
// run check memcached - end
751+
734752
// Get Enabled backends from customServiceConfig and run pre backend conditions
735753
availableBackends := glancev1.GetEnabledBackends(instance.Spec.CustomServiceConfig)
736754
_, hashChanged, err := r.createHashOfBackendConfig(ctx, instance, availableBackends)
@@ -818,10 +836,12 @@ func (r *GlanceAPIReconciler) reconcileNormal(
818836
)
819837
if err != nil {
820838
if k8s_errors.IsNotFound(err) {
839+
// Since the CA cert secret should have been manually created by the user and provided in the spec,
840+
// we treat this as a warning because it means that the service will not be able to start.
821841
instance.Status.Conditions.Set(condition.FalseCondition(
822842
condition.TLSInputReadyCondition,
823-
condition.RequestedReason,
824-
condition.SeverityInfo,
843+
condition.ErrorReason,
844+
condition.SeverityWarning,
825845
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
826846
return ctrl.Result{}, nil
827847
}

test/functional/glanceapi_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ var _ = Describe("Glanceapi controller", func() {
925925
ConditionGetterFunc(GlanceAPIConditionGetter),
926926
condition.TLSInputReadyCondition,
927927
corev1.ConditionFalse,
928-
condition.RequestedReason,
928+
condition.ErrorReason,
929929
fmt.Sprintf("TLSInput is missing: %s", CABundleSecretName),
930930
)
931931
th.ExpectCondition(

0 commit comments

Comments
 (0)