@@ -19,7 +19,6 @@ package controllers
1919import (
2020 "context"
2121 "fmt"
22- "time"
2322
2423 "github.com/openstack-k8s-operators/lib-common/modules/common/tls"
2524 rbacv1 "k8s.io/api/rbac/v1"
@@ -109,6 +108,7 @@ func (r *GlanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
109108 return ctrl.Result {}, nil
110109 }
111110 // Error reading the object - requeue the request.
111+ r .Log .Error (err , fmt .Sprintf ("could not fetch Glance instance %s" , instance .Name ))
112112 return ctrl.Result {}, err
113113 }
114114
@@ -120,6 +120,7 @@ func (r *GlanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
120120 r .Log ,
121121 )
122122 if err != nil {
123+ r .Log .Error (err , fmt .Sprintf ("could not instantiate helper for instance %s" , instance .Name ))
123124 return ctrl.Result {}, err
124125 }
125126
@@ -401,7 +402,7 @@ func (r *GlanceReconciler) reconcileInit(
401402 _ , _ , err := oko_secret .GetSecret (ctx , helper , instance .Spec .Secret , instance .Namespace )
402403 if err != nil {
403404 if k8s_errors .IsNotFound (err ) {
404- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
405+ return glance . ResultRequeue , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
405406 }
406407 return ctrl.Result {}, err
407408 }
@@ -416,7 +417,7 @@ func (r *GlanceReconciler) reconcileInit(
416417 PasswordSelector : instance .Spec .PasswordSelectors .Service ,
417418 }
418419
419- ksSvc := keystonev1 .NewKeystoneService (ksSvcSpec , instance .Namespace , serviceLabels , time . Duration ( 10 ) * time . Second )
420+ ksSvc := keystonev1 .NewKeystoneService (ksSvcSpec , instance .Namespace , serviceLabels , glance . NormalDuration )
420421 ctrlResult , err := ksSvc .CreateOrPatch (ctx , helper )
421422 if err != nil {
422423 return ctrlResult , err
@@ -448,7 +449,7 @@ func (r *GlanceReconciler) reconcileInit(
448449 jobDef ,
449450 glancev1 .DbSyncHash ,
450451 instance .Spec .PreserveJobs ,
451- time . Duration ( 5 ) * time . Second ,
452+ glance . ShortDuration ,
452453 dbSyncHash ,
453454 )
454455 ctrlResult , err = dbSyncjob .DoJob (
@@ -486,26 +487,6 @@ func (r *GlanceReconciler) reconcileInit(
486487 return ctrl.Result {}, nil
487488}
488489
489- func (r * GlanceReconciler ) reconcileUpdate (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
490- r .Log .Info (fmt .Sprintf ("Reconciling Service '%s' update" , instance .Name ))
491-
492- // TODO: should have minor update tasks if required
493- // - delete dbsync hash from status to rerun it?
494-
495- r .Log .Info (fmt .Sprintf ("Reconciled Service '%s' update successfully" , instance .Name ))
496- return ctrl.Result {}, nil
497- }
498-
499- func (r * GlanceReconciler ) reconcileUpgrade (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
500- r .Log .Info (fmt .Sprintf ("Reconciling Service '%s' upgrade" , instance .Name ))
501-
502- // TODO: should have major version upgrade tasks
503- // -delete dbsync hash from status to rerun it?
504-
505- r .Log .Info (fmt .Sprintf ("Reconciled Service '%s' upgrade successfully" , instance .Name ))
506- return ctrl.Result {}, nil
507- }
508-
509490func (r * GlanceReconciler ) reconcileNormal (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
510491 r .Log .Info (fmt .Sprintf ("Reconciling Service '%s'" , instance .Name ))
511492
@@ -549,7 +530,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
549530 condition .RequestedReason ,
550531 condition .SeverityInfo ,
551532 condition .MemcachedReadyWaitingMessage ))
552- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("memcached %s not found" , instance .Spec .MemcachedInstance )
533+ return glance . ResultRequeue , fmt .Errorf ("memcached %s not found" , instance .Spec .MemcachedInstance )
553534 }
554535 instance .Status .Conditions .Set (condition .FalseCondition (
555536 condition .MemcachedReadyCondition ,
@@ -566,7 +547,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
566547 condition .RequestedReason ,
567548 condition .SeverityInfo ,
568549 condition .MemcachedReadyWaitingMessage ))
569- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("memcached %s is not ready" , memcached .Name )
550+ return glance . ResultRequeue , fmt .Errorf ("memcached %s is not ready" , memcached .Name )
570551 }
571552 // Mark the Memcached Service as Ready if we get to this point with no errors
572553 instance .Status .Conditions .MarkTrue (
@@ -584,7 +565,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
584565 condition .RequestedReason ,
585566 condition .SeverityInfo ,
586567 condition .InputReadyWaitingMessage ))
587- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
568+ return glance . ResultRequeue , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
588569 }
589570 instance .Status .Conditions .Set (condition .FalseCondition (
590571 condition .InputReadyCondition ,
@@ -643,22 +624,6 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
643624 return ctrlResult , nil
644625 }
645626
646- // Handle service update
647- ctrlResult , err = r .reconcileUpdate (ctx , instance , helper )
648- if err != nil {
649- return ctrlResult , err
650- } else if (ctrlResult != ctrl.Result {}) {
651- return ctrlResult , nil
652- }
653-
654- // Handle service upgrade
655- ctrlResult , err = r .reconcileUpgrade (ctx , instance , helper )
656- if err != nil {
657- return ctrlResult , err
658- } else if (ctrlResult != ctrl.Result {}) {
659- return ctrlResult , nil
660- }
661-
662627 //
663628 // Reconcile the GlanceAPI deployment
664629 //
@@ -1052,7 +1017,7 @@ func (r *GlanceReconciler) ensureDBPurgeJob(
10521017
10531018 dbPurgeCronJob := cronjob .NewCronJob (
10541019 cronjobDef ,
1055- 5 * time . Second ,
1020+ glance . ShortDuration ,
10561021 )
10571022 ctrlResult , err := dbPurgeCronJob .CreateOrPatch (ctx , h )
10581023 if err != nil {
0 commit comments