@@ -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
@@ -408,7 +409,7 @@ func (r *GlanceReconciler) reconcileInit(
408409 _ , _ , err := oko_secret .GetSecret (ctx , helper , instance .Spec .Secret , instance .Namespace )
409410 if err != nil {
410411 if k8s_errors .IsNotFound (err ) {
411- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
412+ return glance . ResultRequeue , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
412413 }
413414 return ctrl.Result {}, err
414415 }
@@ -423,7 +424,7 @@ func (r *GlanceReconciler) reconcileInit(
423424 PasswordSelector : instance .Spec .PasswordSelectors .Service ,
424425 }
425426
426- ksSvc := keystonev1 .NewKeystoneService (ksSvcSpec , instance .Namespace , serviceLabels , time . Duration ( 10 ) * time . Second )
427+ ksSvc := keystonev1 .NewKeystoneService (ksSvcSpec , instance .Namespace , serviceLabels , glance . NormalDuration )
427428 ctrlResult , err := ksSvc .CreateOrPatch (ctx , helper )
428429 if err != nil {
429430 return ctrlResult , err
@@ -455,7 +456,7 @@ func (r *GlanceReconciler) reconcileInit(
455456 jobDef ,
456457 glancev1 .DbSyncHash ,
457458 instance .Spec .PreserveJobs ,
458- time . Duration ( 5 ) * time . Second ,
459+ glance . ShortDuration ,
459460 dbSyncHash ,
460461 )
461462 ctrlResult , err = dbSyncjob .DoJob (
@@ -489,26 +490,6 @@ func (r *GlanceReconciler) reconcileInit(
489490 return ctrl.Result {}, nil
490491}
491492
492- func (r * GlanceReconciler ) reconcileUpdate (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
493- r .Log .Info (fmt .Sprintf ("Reconciling Service '%s' update" , instance .Name ))
494-
495- // TODO: should have minor update tasks if required
496- // - delete dbsync hash from status to rerun it?
497-
498- r .Log .Info (fmt .Sprintf ("Reconciled Service '%s' update successfully" , instance .Name ))
499- return ctrl.Result {}, nil
500- }
501-
502- func (r * GlanceReconciler ) reconcileUpgrade (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
503- r .Log .Info (fmt .Sprintf ("Reconciling Service '%s' upgrade" , instance .Name ))
504-
505- // TODO: should have major version upgrade tasks
506- // -delete dbsync hash from status to rerun it?
507-
508- r .Log .Info (fmt .Sprintf ("Reconciled Service '%s' upgrade successfully" , instance .Name ))
509- return ctrl.Result {}, nil
510- }
511-
512493func (r * GlanceReconciler ) reconcileNormal (ctx context.Context , instance * glancev1.Glance , helper * helper.Helper ) (ctrl.Result , error ) {
513494 r .Log .Info (fmt .Sprintf ("Reconciling Service '%s'" , instance .Name ))
514495
@@ -552,7 +533,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
552533 condition .RequestedReason ,
553534 condition .SeverityInfo ,
554535 condition .MemcachedReadyWaitingMessage ))
555- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("memcached %s not found" , instance .Spec .MemcachedInstance )
536+ return glance . ResultRequeue , fmt .Errorf ("memcached %s not found" , instance .Spec .MemcachedInstance )
556537 }
557538 instance .Status .Conditions .Set (condition .FalseCondition (
558539 condition .MemcachedReadyCondition ,
@@ -569,7 +550,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
569550 condition .RequestedReason ,
570551 condition .SeverityInfo ,
571552 condition .MemcachedReadyWaitingMessage ))
572- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("memcached %s is not ready" , memcached .Name )
553+ return glance . ResultRequeue , fmt .Errorf ("memcached %s is not ready" , memcached .Name )
573554 }
574555 // Mark the Memcached Service as Ready if we get to this point with no errors
575556 instance .Status .Conditions .MarkTrue (
@@ -587,7 +568,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
587568 condition .RequestedReason ,
588569 condition .SeverityInfo ,
589570 condition .InputReadyWaitingMessage ))
590- return ctrl. Result { RequeueAfter : time . Duration ( 10 ) * time . Second } , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
571+ return glance . ResultRequeue , fmt .Errorf ("OpenStack secret %s not found" , instance .Spec .Secret )
591572 }
592573 instance .Status .Conditions .Set (condition .FalseCondition (
593574 condition .InputReadyCondition ,
@@ -646,22 +627,6 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
646627 return ctrlResult , nil
647628 }
648629
649- // Handle service update
650- ctrlResult , err = r .reconcileUpdate (ctx , instance , helper )
651- if err != nil {
652- return ctrlResult , err
653- } else if (ctrlResult != ctrl.Result {}) {
654- return ctrlResult , nil
655- }
656-
657- // Handle service upgrade
658- ctrlResult , err = r .reconcileUpgrade (ctx , instance , helper )
659- if err != nil {
660- return ctrlResult , err
661- } else if (ctrlResult != ctrl.Result {}) {
662- return ctrlResult , nil
663- }
664-
665630 //
666631 // Reconcile the GlanceAPI deployment
667632 //
@@ -1054,7 +1019,7 @@ func (r *GlanceReconciler) ensureDBPurgeJob(
10541019
10551020 dbPurgeCronJob := cronjob .NewCronJob (
10561021 cronjobDef ,
1057- 5 * time . Second ,
1022+ glance . ShortDuration ,
10581023 )
10591024 ctrlResult , err := dbPurgeCronJob .CreateOrPatch (ctx , h )
10601025 if err != nil {
0 commit comments