@@ -93,7 +93,7 @@ func (r *AuthenticationReconciler) handleRoutes(ctx context.Context, req ctrl.Re
93
93
// traffic.
94
94
func (r * AuthenticationReconciler ) checkForZenFrontDoor (ctx context.Context , authCR * operatorv1alpha1.Authentication ) (result * ctrl.Result , err error ) {
95
95
reqLogger := logf .FromContext (ctx )
96
- if shouldHaveRoutes (authCR , & r .DiscoveryClient ) {
96
+ if shouldNotUseCPDHost (authCR , & r .DiscoveryClient ) {
97
97
reqLogger .Info ("IM Routes will be created" )
98
98
return subreconciler .ContinueReconciling ()
99
99
}
@@ -320,37 +320,10 @@ func (r *AuthenticationReconciler) reconcileRoute(authCR *operatorv1alpha1.Authe
320
320
reqLogger .Info ("Reconciling route" , "annotations" , fields .Annotations , "routeHost" , fields .RouteHost , "routePath" , fields .RoutePath )
321
321
322
322
fCtx := logf .IntoContext (ctx , reqLogger )
323
- if fields .Name != IMCrtAuthRouteName {
324
- if shouldNotHaveRoutes (authCR , & r .DiscoveryClient ) {
325
- return r .ensureRouteDoesNotExist (fCtx , authCR , fields )
326
- }
327
- }
328
-
329
323
return r .ensureRouteExists (fCtx , authCR , fields )
330
324
}
331
325
}
332
326
333
- func (r * AuthenticationReconciler ) ensureRouteDoesNotExist (ctx context.Context , authCR * operatorv1alpha1.Authentication , fields * reconcileRouteFields ) (result * ctrl.Result , err error ) {
334
- reqLogger := logf .FromContext (ctx )
335
- reqLogger .Info ("Determined Route should not exist; removing if present" )
336
- observedRoute := & routev1.Route {}
337
- err = r .Get (ctx , types.NamespacedName {Name : fields .Name , Namespace : authCR .Namespace }, observedRoute )
338
- if k8sErrors .IsNotFound (err ) {
339
- return subreconciler .ContinueReconciling ()
340
- } else if err != nil {
341
- reqLogger .Error (err , "Failed to get existing route for reconciliation" )
342
- return subreconciler .RequeueWithError (err )
343
- }
344
- err = r .Delete (ctx , observedRoute )
345
- if err != nil {
346
- reqLogger .Error (err , "Failed to delete the Route" )
347
- return subreconciler .RequeueWithError (err )
348
- }
349
- reqLogger .Info ("Successfully deleted the Route" )
350
-
351
- return subreconciler .RequeueWithDelay (defaultLowerWait )
352
- }
353
-
354
327
func (r * AuthenticationReconciler ) ensureRouteExists (ctx context.Context , authCR * operatorv1alpha1.Authentication , fields * reconcileRouteFields ) (result * ctrl.Result , err error ) {
355
328
reqLogger := logf .FromContext (ctx )
356
329
calculatedRoute , err := r .newRoute (authCR , fields )
@@ -436,12 +409,12 @@ func (r *AuthenticationReconciler) ensureRouteExists(ctx context.Context, authCR
436
409
return subreconciler .ContinueReconciling ()
437
410
}
438
411
439
- func shouldNotHaveRoutes (authCR * operatorv1alpha1.Authentication , dc * discovery.DiscoveryClient ) bool {
412
+ func shouldUseCPDHost (authCR * operatorv1alpha1.Authentication , dc * discovery.DiscoveryClient ) bool {
440
413
return authCR .Spec .Config .ZenFrontDoor && ctrlcommon .ClusterHasZenExtensionGroupVersion (dc )
441
414
}
442
415
443
- func shouldHaveRoutes (authCR * operatorv1alpha1.Authentication , dc * discovery.DiscoveryClient ) bool {
444
- return ! shouldNotHaveRoutes (authCR , dc )
416
+ func shouldNotUseCPDHost (authCR * operatorv1alpha1.Authentication , dc * discovery.DiscoveryClient ) bool {
417
+ return ! shouldUseCPDHost (authCR , dc )
445
418
}
446
419
447
420
// Use DeepEqual to determine if 2 routes are equal.
@@ -588,6 +561,9 @@ func (r *AuthenticationReconciler) getClusterAddress(authCR *operatorv1alpha1.Au
588
561
clusterInfoConfigMap := & corev1.ConfigMap {}
589
562
590
563
clusterAddressFieldName := "cluster_address"
564
+ if shouldUseCPDHost (authCR , & r .DiscoveryClient ) {
565
+ clusterAddressFieldName = "cluster_address_auth"
566
+ }
591
567
592
568
fns := []subreconciler.Fn {
593
569
r .getClusterInfoConfigMap (authCR , clusterInfoConfigMap ),
0 commit comments