@@ -23,10 +23,8 @@ import (
2323 "time"
2424
2525 batchv1 "k8s.io/api/batch/v1"
26- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27-
28- "k8s.io/apimachinery/pkg/api/errors"
2926 "k8s.io/apimachinery/pkg/api/resource"
27+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3028 "k8s.io/apimachinery/pkg/fields"
3129 "k8s.io/apimachinery/pkg/runtime"
3230 "k8s.io/apimachinery/pkg/types"
@@ -152,6 +150,7 @@ func (r *GlanceAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
152150 instance .Status .Conditions = condition.Conditions {}
153151 // initialize conditions used later as Status=Unknown
154152 cl := condition .CreateList (
153+ condition .UnknownCondition (glancev1 .CinderCondition , condition .InitReason , glancev1 .CinderInitMessage ),
155154 condition .UnknownCondition (condition .ExposeServiceReadyCondition , condition .InitReason , condition .ExposeServiceReadyInitMessage ),
156155 condition .UnknownCondition (condition .InputReadyCondition , condition .InitReason , condition .InputReadyInitMessage ),
157156 condition .UnknownCondition (condition .ServiceConfigReadyCondition , condition .InitReason , condition .ServiceConfigReadyInitMessage ),
@@ -583,12 +582,16 @@ func (r *GlanceAPIReconciler) reconcileNormal(ctx context.Context, instance *gla
583582 case backendToken [1 ] == "cinder" :
584583 cinder := & cinderv1.Cinder {}
585584 err := r .Get (ctx , types.NamespacedName {Namespace : instance .Namespace , Name : glance .CinderName }, cinder )
586- if err != nil {
587- if errors .IsNotFound (err ) {
588- // Request object not found, can't run GlanceAPI with this config
589- r .Log .Info ("Cinder resource not found. Waiting for it to be deployed" )
590- return ctrl.Result {RequeueAfter : time .Duration (10 ) * time .Second }, nil
591- }
585+ if err != nil && ! k8s_errors .IsNotFound (err ) {
586+ // Request object not found, GlanceAPI can't be executed with this config
587+ r .Log .Info ("Cinder resource not found. Waiting for it to be deployed" )
588+ instance .Status .Conditions .Set (condition .FalseCondition (
589+ glancev1 .CinderCondition ,
590+ condition .RequestedReason ,
591+ condition .SeverityInfo ,
592+ glancev1 .CinderInitMessage ),
593+ )
594+ return ctrl.Result {RequeueAfter : time .Duration (10 ) * time .Second }, nil
592595 }
593596 // Cinder CR is found, we can unblock glance deployment because
594597 // it represents a valid backend.
@@ -599,6 +602,10 @@ func (r *GlanceAPIReconciler) reconcileNormal(ctx context.Context, instance *gla
599602 imageConv = true
600603 }
601604 }
605+ // If we reach this point, it means that either Cinder is not a backend for Glance
606+ // or, in case Cinder is a backend for the current GlanceAPI, the associated resources
607+ // are present in the control plane
608+ instance .Status .Conditions .MarkTrue (glancev1 .CinderCondition , glancev1 .CinderReadyMessage )
602609
603610 // Generate service config
604611 err = r .generateServiceConfig (ctx , helper , instance , & configVars , imageConv )
@@ -684,7 +691,6 @@ func (r *GlanceAPIReconciler) reconcileNormal(ctx context.Context, instance *gla
684691 //
685692 // TODO check when/if Init, Update, or Upgrade should/could be skipped
686693 //
687-
688694 var serviceAnnotations map [string ]string
689695 // networks to attach to
690696 serviceAnnotations , ctrlResult , err = ensureNAD (ctx , & instance .Status .Conditions , instance .Spec .NetworkAttachments , helper )
@@ -1228,7 +1234,7 @@ func (r *GlanceAPIReconciler) glanceAPIRefresh(
12281234) error {
12291235 sts , err := statefulset .GetStatefulSetWithName (ctx , h , fmt .Sprintf ("%s-api" , instance .Name ), instance .Namespace )
12301236 if err != nil {
1231- if errors .IsNotFound (err ) {
1237+ if k8s_errors .IsNotFound (err ) {
12321238 // Request object not found
12331239 r .Log .Info (fmt .Sprintf ("GlanceAPI %s-api: Statefulset not found." , instance .Name ))
12341240 return nil
0 commit comments