feature(leader_election): flag to disable leader election feature on controller (#11064)
This commit is contained in:
parent
a302cc5cca
commit
9b63559cbb
11 changed files with 195 additions and 18 deletions
|
|
@ -146,6 +146,9 @@ Requires the update-status parameter.`)
|
|||
enableSSLPassthrough = flags.Bool("enable-ssl-passthrough", false,
|
||||
`Enable SSL Passthrough.`)
|
||||
|
||||
disableLeaderElection = flags.Bool("disable-leader-election", false,
|
||||
`Disable Leader Election on NGINX Controller.`)
|
||||
|
||||
disableServiceExternalName = flags.Bool("disable-svc-external-name", false,
|
||||
`Disable support for Services of type ExternalName.`)
|
||||
|
||||
|
|
@ -333,6 +336,7 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
|
|||
MonitorMaxBatchSize: *monitorMaxBatchSize,
|
||||
DisableServiceExternalName: *disableServiceExternalName,
|
||||
EnableSSLPassthrough: *enableSSLPassthrough,
|
||||
DisableLeaderElection: *disableLeaderElection,
|
||||
ResyncPeriod: *resyncPeriod,
|
||||
DefaultService: *defaultSvc,
|
||||
Namespace: *watchNamespace,
|
||||
|
|
|
|||
|
|
@ -109,3 +109,37 @@ func TestMaxmindRetryDownload(t *testing.T) {
|
|||
t.Fatalf("Expected an error parsing flags but none returned")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisableLeaderElectionFlag(t *testing.T) {
|
||||
ResetForTesting(func() { t.Fatal("Parsing failed") })
|
||||
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = []string{"cmd", "--disable-leader-election", "--http-port", "80", "--https-port", "443"}
|
||||
|
||||
_, conf, err := ParseFlags()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error parsing default flags: %v", err)
|
||||
}
|
||||
|
||||
if !conf.DisableLeaderElection {
|
||||
t.Fatalf("Expected --disable-leader-election and conf.DisableLeaderElection as true, but found: %v", conf.DisableLeaderElection)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIfLeaderElectionDisabledFlagIsFalse(t *testing.T) {
|
||||
ResetForTesting(func() { t.Fatal("Parsing failed") })
|
||||
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = []string{"cmd", "--http-port", "80", "--https-port", "443"}
|
||||
|
||||
_, conf, err := ParseFlags()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error parsing default flags: %v", err)
|
||||
}
|
||||
|
||||
if conf.DisableLeaderElection {
|
||||
t.Fatalf("Expected --disable-leader-election and conf.DisableLeaderElection as false, but found: %v", conf.DisableLeaderElection)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue