@@ -431,7 +431,9 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
431431
432432 apiEndpoints , result , err := r .ensureServiceExposed (ctx , h , instance )
433433
434- if err != nil {
434+ if (err != nil || result != ctrl.Result {}) {
435+ // We can ignore RequeueAfter as we are watching the Service resource
436+ // but we have to return while waiting for the service to be exposed
435437 return ctrl.Result {}, err
436438 }
437439
@@ -441,10 +443,10 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
441443 }
442444
443445 result , err = r .ensureKeystoneEndpoint (ctx , h , instance , apiEndpoints )
444- if err != nil {
446+ if (err != nil || result != ctrl.Result {}) {
447+ // We can ignore RequeueAfter as we are watching the KeystoneEndpoint resource
445448 return ctrl.Result {}, err
446449 }
447-
448450 result , err = r .ensureDbSync (ctx , instance , h , serviceAnnotations )
449451 if (err != nil || result != ctrl.Result {}) {
450452 return result , err
@@ -482,6 +484,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
482484 }
483485 apiEndpoints := make (map [string ]string )
484486
487+ serviceLabels := getServiceLabels (instance )
485488 for endpointType , data := range placementEndpoints {
486489 endpointTypeStr := string (endpointType )
487490 endpointName := placement .ServiceName + "-" + endpointTypeStr
@@ -492,7 +495,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
492495 }
493496
494497 exportLabels := util .MergeStringMaps (
495- getServiceLabels ( instance ) ,
498+ serviceLabels ,
496499 map [string ]string {
497500 service .AnnotationEndpointKey : endpointTypeStr ,
498501 },
@@ -504,7 +507,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
504507 Name : endpointName ,
505508 Namespace : instance .Namespace ,
506509 Labels : exportLabels ,
507- Selector : getServiceLabels ( instance ) ,
510+ Selector : serviceLabels ,
508511 Port : service.GenericServicePort {
509512 Name : endpointName ,
510513 Port : data .Port ,
@@ -522,7 +525,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
522525 condition .ExposeServiceReadyErrorMessage ,
523526 err .Error ()))
524527
525- return nil , ctrl.Result {}, err
528+ return apiEndpoints , ctrl.Result {}, err
526529 }
527530
528531 svc .AddAnnotation (map [string ]string {
@@ -554,14 +557,14 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
554557 condition .ExposeServiceReadyErrorMessage ,
555558 err .Error ()))
556559
557- return nil , ctrlResult , err
560+ return apiEndpoints , ctrlResult , err
558561 } else if (ctrlResult != ctrl.Result {}) {
559562 instance .Status .Conditions .Set (condition .FalseCondition (
560563 condition .ExposeServiceReadyCondition ,
561564 condition .RequestedReason ,
562565 condition .SeverityInfo ,
563566 condition .ExposeServiceReadyRunningMessage ))
564- return nil , ctrlResult , nil
567+ return apiEndpoints , ctrlResult , nil
565568 }
566569 // create service - end
567570
@@ -574,7 +577,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
574577 apiEndpoints [string (endpointType )], err = svc .GetAPIEndpoint (
575578 svcOverride .EndpointURL , data .Protocol , data .Path )
576579 if err != nil {
577- return nil , ctrl.Result {}, err
580+ return apiEndpoints , ctrl.Result {}, err
578581 }
579582 }
580583
0 commit comments