diff --git a/pkg/flags/flags.go b/pkg/flags/flags.go index 0c8540cc1b..fd0bea464b 100644 --- a/pkg/flags/flags.go +++ b/pkg/flags/flags.go @@ -61,39 +61,41 @@ var ( // F are global flags for the controller. F = struct { APIServerHost string + ASMConfigMapBasedConfigCMName string + ASMConfigMapBasedConfigNamespace string ClusterName string ConfigFilePath string - DefaultSvcHealthCheckPath string DefaultSvc string + DefaultSvcHealthCheckPath string DefaultSvcPortName string DeleteAllOnQuit bool - EnableFrontendConfig bool - GCERateLimit RateLimitSpecs GCEOperationPollInterval time.Duration + GCERateLimit RateLimitSpecs HealthCheckPath string HealthzPort int InCluster bool IngressClass string KubeConfigFile string - ResyncPeriod time.Duration - Version bool - WatchNamespace string - NodePortRanges PortRanges NegGCPeriod time.Duration - EnableReadinessReflector bool - FinalizerAdd bool - FinalizerRemove bool - EnableL7Ilb bool - EnableASMConfigMapBasedConfig bool - ASMConfigMapBasedConfigNamespace string - ASMConfigMapBasedConfigCMName string - EnableNonGCPMode bool - EnableDeleteUnusedFrontends bool - EnableV2FrontendNamer bool + NodePortRanges PortRanges + ResyncPeriod time.Duration RunIngressController bool RunL4Controller bool - - LeaderElection LeaderElectionConfiguration + Version bool + WatchNamespace string + LeaderElection LeaderElectionConfiguration + + // Feature flags should be named Enablexxx. + EnableASMConfigMapBasedConfig bool + EnableBackendConfigHealthCheck bool + EnableDeleteUnusedFrontends bool + EnableFrontendConfig bool + EnableL7Ilb bool + EnableNonGCPMode bool + EnableReadinessReflector bool + EnableV2FrontendNamer bool + FinalizerAdd bool // Should have been named Enablexxx. + FinalizerRemove bool // Should have been named Enablexxx. }{} ) @@ -214,6 +216,7 @@ L7 load balancing. CSV values accepted. Example: -node-port-ranges=80,8080,400-5 flag.BoolVar(&F.EnableV2FrontendNamer, "enable-v2-frontend-namer", false, "Enable v2 ingress frontend naming policy.") flag.BoolVar(&F.RunIngressController, "run-ingress-controller", true, `Optional, whether or not to run IngressController as part of glbc. If set to false, ingress resources will not be processed. Only the L4 Service controller will be run, if that flag is set to true.`) flag.BoolVar(&F.RunL4Controller, "run-l4-controller", false, `Optional, whether or not to run L4 Service Controller as part of glbc. If set to true, services of Type:LoadBalancer with Internal annotation will be processed by this controller.`) + flag.BoolVar(&F.EnableBackendConfigHealthCheck, "enable-backendconfig-healthcheck", false, "Enable configuration of HealthChecks from the BackendConfig") } type RateLimitSpecs struct { diff --git a/pkg/healthchecks/healthchecks.go b/pkg/healthchecks/healthchecks.go index 4561e34510..34549addd7 100644 --- a/pkg/healthchecks/healthchecks.go +++ b/pkg/healthchecks/healthchecks.go @@ -120,9 +120,12 @@ func (h *HealthChecks) SyncServicePort(sp *utils.ServicePort, probe *v1.Probe) ( applyProbeSettingsToHC(probe, hc) } var bchcc *backendconfigv1.HealthCheckConfig - if sp.BackendConfig != nil { + if flags.F.EnableBackendConfigHealthCheck && sp.BackendConfig != nil { bchcc = sp.BackendConfig.Spec.HealthCheck } + if bchcc != nil { + klog.V(2).Infof("ServicePort %v has BackendConfig healthcheck override", sp.ID) + } return h.sync(hc, bchcc) } diff --git a/pkg/healthchecks/healthchecks_test.go b/pkg/healthchecks/healthchecks_test.go index 87c8230db3..ddc4dc0be8 100644 --- a/pkg/healthchecks/healthchecks_test.go +++ b/pkg/healthchecks/healthchecks_test.go @@ -36,6 +36,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-gce/pkg/annotations" backendconfigv1 "k8s.io/ingress-gce/pkg/apis/backendconfig/v1" + "k8s.io/ingress-gce/pkg/flags" "k8s.io/ingress-gce/pkg/utils" namer_util "k8s.io/ingress-gce/pkg/utils/namer" "k8s.io/klog" @@ -804,6 +805,11 @@ func setupMockUpdate(mock *cloud.MockGCE) { } func TestSyncServicePort(t *testing.T) { + // No parallel(). + oldEnable := flags.F.EnableBackendConfigHealthCheck + flags.F.EnableBackendConfigHealthCheck = true + defer func() { flags.F.EnableBackendConfigHealthCheck = oldEnable }() + type tc struct { desc string setup func(*cloud.MockGCE)