@@ -125,6 +125,7 @@ var (
125125 operandNamespace = operatorcontroller .DefaultOperandNamespace
126126 defaultName = types.NamespacedName {Namespace : operatorNamespace , Name : manifests .DefaultIngressControllerName }
127127 clusterConfigName = types.NamespacedName {Namespace : operatorNamespace , Name : manifests .ClusterIngressConfigName }
128+ ccmDeploymentName = types.NamespacedName {Namespace : "openshift-cloud-controller-manager" , Name : "aws-cloud-controller-manager" }
128129
129130 // Platforms that need a DNS "warmup" period for internal (inside the test cluster) DNS resolution.
130131 // The warmup period is a period of delay before the first query is executed to avoid negative caching.
@@ -142,6 +143,13 @@ const (
142143 // cluster (which may be on different platforms) and any negative caching along the way. As of writing this, AWS
143144 // typically resolves within ~1 minute (see OCPBUGS-14966), while IBMCloud takes ~7 minutes (see OCPBUGS-48780).
144145 dnsResolutionTimeout = 10 * time .Minute
146+
147+ // ccmConfigAnnotation is an annotation that exists on CloudControllerManager
148+ // and contains a hash of the current infrastructure configuration.
149+ // It is used to signal to CCM deployment a configuration change that needs
150+ // a rollout update, and can be used by tests to also detect changes on CCM
151+ // deployment
152+ ccmConfigAnnotation = "operator.openshift.io/config-hash"
145153)
146154
147155func init () {
@@ -2596,110 +2604,84 @@ func TestContainerLoggingMinLength(t *testing.T) {
25962604}
25972605
25982606func TestIngressControllerCustomEndpoints (t * testing.T ) {
2607+ if infraConfig .Status .ControlPlaneTopology == configv1 .ExternalTopologyMode {
2608+ t .Skipf ("skipping TestIngressControllerCustomEndpoints test due to controlplanetopology: %v" , infraConfig .Status .ControlPlaneTopology )
2609+ }
25992610 platform := infraConfig .Status .PlatformStatus
26002611 if platform == nil {
26012612 t .Fatalf ("platform status is missing for infrastructure %s" , infraConfig .Name )
26022613 }
2603- switch platform .Type {
2604- case configv1 .AWSPlatformType :
2605- switch {
2606- case platform .AWS == nil :
2607- t .Fatalf ("aws platform status is missing for infrastructure %s" , infraConfig .Name )
2608- case len (platform .AWS .ServiceEndpoints ) != 0 :
2609- t .Skipf ("custom endpoints detected for infrastructure %s, skipping TestIngressControllerCustomEndpoints" ,
2610- infraConfig .Name )
2611- case len (platform .AWS .Region ) == 0 :
2612- t .Fatalf ("region is missing from aws platform status for infrastructure %s" , infraConfig .Name )
2613- case platform .AWS .Region == endpoints .CnNorth1RegionID || platform .AWS .Region == endpoints .CnNorthwest1RegionID :
2614- t .Skipf ("region %s or %s detected for infrastructure %s, skipping TestIngressControllerCustomEndpoints" ,
2615- endpoints .CnNorth1RegionID , endpoints .CnNorthwest1RegionID , infraConfig .Name )
2616- }
2617- route53Endpoint := configv1.AWSServiceEndpoint {
2618- Name : "route53" ,
2619- // AWS Route 53 is a non-regionalized service, so the endpoint URL
2620- // does not include a region.
2621- URL : "https://route53.amazonaws.com" ,
2622- }
2623- taggingEndpoint := configv1.AWSServiceEndpoint {
2624- Name : "tagging" ,
2625- // us-east-1 region is required to get hosted zone resources
2626- // since route 53 is a non-regionalized service.
2627- URL : "https://tagging.us-east-1.amazonaws.com" ,
2628- }
2629- elbEndpoint := configv1.AWSServiceEndpoint {
2630- Name : "elasticloadbalancing" ,
2631- URL : fmt .Sprintf ("https://elasticloadbalancing.%s.amazonaws.com" , platform .AWS .Region ),
2632- }
2633-
2634- ccmDeploymentName := types.NamespacedName {Namespace : "openshift-cloud-controller-manager" , Name : "aws-cloud-controller-manager" }
2635- oldCCMDeployment , err := retrieveDeployment (ccmDeploymentName )
2636- if err != nil {
2637- t .Fatalf ("error getting CCM deployment: %v\n " , err )
2638- }
2639- oldConfigHash := retrieveCCMConfigurationHash (oldCCMDeployment )
2640- if oldConfigHash == "" {
2641- t .Fatalf ("CCM does not have a config hash, this should never happen: %v\n " , oldCCMDeployment )
2642- }
26432614
2644- if err := updateInfrastructureConfigSpecWithRetryOnConflict (t , types.NamespacedName {Name : "cluster" }, timeout , func (spec * configv1.InfrastructureSpec ) {
2645- spec .PlatformSpec .AWS = & configv1.AWSPlatformSpec {
2646- ServiceEndpoints : []configv1.AWSServiceEndpoint {
2647- route53Endpoint ,
2648- taggingEndpoint ,
2649- elbEndpoint ,
2650- },
2651- }
2615+ if platform .Type != configv1 .AWSPlatformType {
2616+ t .Skipf ("skipping TestIngressControllerCustomEndpoints test due to platform type: %s" , platform .Type )
2617+ }
2618+
2619+ switch {
2620+ case platform .AWS == nil :
2621+ t .Fatalf ("aws platform status is missing for infrastructure %s" , infraConfig .Name )
2622+ case len (platform .AWS .ServiceEndpoints ) != 0 :
2623+ t .Skipf ("custom endpoints detected for infrastructure %s, skipping TestIngressControllerCustomEndpoints" ,
2624+ infraConfig .Name )
2625+ case len (platform .AWS .Region ) == 0 :
2626+ t .Fatalf ("region is missing from aws platform status for infrastructure %s" , infraConfig .Name )
2627+ case platform .AWS .Region == endpoints .CnNorth1RegionID || platform .AWS .Region == endpoints .CnNorthwest1RegionID :
2628+ t .Skipf ("region %s or %s detected for infrastructure %s, skipping TestIngressControllerCustomEndpoints" ,
2629+ endpoints .CnNorth1RegionID , endpoints .CnNorthwest1RegionID , infraConfig .Name )
2630+ }
2631+
2632+ route53Endpoint := configv1.AWSServiceEndpoint {
2633+ Name : "route53" ,
2634+ // AWS Route 53 is a non-regionalized service, so the endpoint URL
2635+ // does not include a region.
2636+ URL : "https://route53.amazonaws.com" ,
2637+ }
2638+ taggingEndpoint := configv1.AWSServiceEndpoint {
2639+ Name : "tagging" ,
2640+ // us-east-1 region is required to get hosted zone resources
2641+ // since route 53 is a non-regionalized service.
2642+ URL : "https://tagging.us-east-1.amazonaws.com" ,
2643+ }
2644+ elbEndpoint := configv1.AWSServiceEndpoint {
2645+ Name : "elasticloadbalancing" ,
2646+ URL : fmt .Sprintf ("https://elasticloadbalancing.%s.amazonaws.com" , platform .AWS .Region ),
2647+ }
2648+
2649+ oldCCMDeployment := waitForCCMReadiness (t , 5 * time .Minute , "" )
2650+ oldConfigHash := retrieveCCMConfigurationHash (oldCCMDeployment )
2651+ if oldConfigHash == "" {
2652+ t .Fatalf ("CCM does not have a config hash, this should never happen: %v" , oldCCMDeployment )
2653+ }
2654+
2655+ if err := updateInfrastructureConfigWithRetryOnConflict (t , types.NamespacedName {Name : "cluster" }, timeout , func (spec * configv1.InfrastructureSpec ) {
2656+ spec .PlatformSpec .AWS = & configv1.AWSPlatformSpec {
2657+ ServiceEndpoints : []configv1.AWSServiceEndpoint {
2658+ route53Endpoint ,
2659+ taggingEndpoint ,
2660+ elbEndpoint ,
2661+ },
2662+ }
2663+ }); err != nil {
2664+ t .Fatalf ("failed to update infrastructure config: %v" , err )
2665+ }
2666+ defer func () {
2667+ // Remove the custom endpoints from the infrastructure config.
2668+ if err := updateInfrastructureConfigWithRetryOnConflict (t , types.NamespacedName {Name : "cluster" }, timeout , func (spec * configv1.InfrastructureSpec ) {
2669+ spec .PlatformSpec .AWS = nil
26522670 }); err != nil {
2653- t .Fatalf ("failed to update infrastructure config: %v\n " , err )
2671+ t .Fatalf ("failed to update infrastructure config: %v" , err )
26542672 }
2655- defer func () {
2656- // Remove the custom endpoints from the infrastructure config.
2657- if err := updateInfrastructureConfigSpecWithRetryOnConflict (t , types.NamespacedName {Name : "cluster" }, timeout , func (spec * configv1.InfrastructureSpec ) {
2658- spec .PlatformSpec .AWS = nil
2659- }); err != nil {
2660- t .Fatalf ("failed to update infrastructure config: %v" , err )
2661- }
2662- }()
2663-
2664- // Wait for infrastructure status to update with custom endpoints,
2665- // for CCM deploy to get a new configuration hash and for pods to be scheduled
2666- // and available
2667- // This configuration change and replicas available may take up to 5 minutes, depending on
2668- // the environment load
2669- if err := wait .PollUntilContextTimeout (context .TODO (), 1 * time .Second , 5 * time .Minute , false , func (ctx context.Context ) (done bool , err error ) {
2670- if err := kclient .Get (ctx , types.NamespacedName {Name : "cluster" }, & infraConfig ); err != nil {
2671- t .Logf ("failed to get infrastructure config: %v\n " , err )
2672- return false , err
2673- }
2674- if len (infraConfig .Status .PlatformStatus .AWS .ServiceEndpoints ) == 0 {
2675- return false , nil
2676- }
2673+ }()
26772674
2678- currentCCMDeployment , err := retrieveDeployment (ccmDeploymentName )
2679- if err != nil {
2680- t .Logf ("error getting CCM deployment: %v\n " , err )
2681- return false , err
2682- }
2683- currentConfigHash := retrieveCCMConfigurationHash (currentCCMDeployment )
2684- if oldConfigHash == currentConfigHash {
2685- t .Log ("new config hash not yet applied to CCM deployment" )
2686- return false , nil
2687- }
2675+ // Wait for infrastructure status to update with custom endpoints,
2676+ // for CCM deploy to get a new configuration hash and for pods to be scheduled
2677+ // and available
2678+ // This configuration change and replicas available may take up to 5 minutes, depending on
2679+ // the environment load
26882680
2689- if currentCCMDeployment .Generation == currentCCMDeployment .Status .ObservedGeneration &&
2690- currentCCMDeployment .Status .Replicas == currentCCMDeployment .Status .ReadyReplicas &&
2691- currentCCMDeployment .Status .Replicas == currentCCMDeployment .Status .UpdatedReplicas &&
2692- currentCCMDeployment .Status .UnavailableReplicas == 0 {
2693- return true , nil
2694- }
2695- return false , nil
2681+ // Wait for CCM to be ready with the new configuration, so we can guarantee that
2682+ // the LoadBalancer will be created correctly
2683+ _ = waitForCCMReadiness (t , 5 * time .Minute , oldConfigHash )
26962684
2697- }); err != nil {
2698- t .Fatalf ("failed to observe status update for infrastructure config %s" , infraConfig .Name )
2699- }
2700- default :
2701- t .Skipf ("skipping TestIngressControllerCustomEndpoints test due to platform type: %s" , platform .Type )
2702- }
27032685 // The default ingresscontroller should surface the expected status conditions.
27042686 if err := waitForIngressControllerCondition (t , kclient , 30 * time .Second , defaultName , availableConditionsForIngressControllerWithLoadBalancer ... ); err != nil {
27052687 t .Fatalf ("did not get expected ingress controller conditions: %v" , err )
0 commit comments