Skip to content

Commit

Permalink
Merge pull request #1040 from bowei/hc-from-bc-2
Browse files Browse the repository at this point in the history
Add feature flag `EnableBackendConfigHealthCheck`
  • Loading branch information
k8s-ci-robot authored Feb 25, 2020
2 parents f60eb43 + 275c994 commit 563263f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
41 changes: 22 additions & 19 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}{}
)

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/healthchecks/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/healthchecks/healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 563263f

Please sign in to comment.