Skip to content

Commit e1fa195

Browse files
authored
Merge pull request kubernetes#76627 from timoreimann/handle-missing-gce-lb-flag-gracefully
Suppress registering GCE LB provider flag if missing on CommandLine.
2 parents c3ebf67 + 16c150c commit e1fa195

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/cloud-controller-manager/app/controllermanager.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package app
1818

1919
import (
2020
"context"
21+
"flag"
2122
"fmt"
2223
"net/http"
2324
"os"
@@ -86,9 +87,12 @@ the cloud specific control loops shipped with Kubernetes.`,
8687
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault.List())
8788
verflag.AddFlags(namedFlagSets.FlagSet("global"))
8889
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name())
89-
// hoist this flag from the global flagset to preserve the commandline until
90-
// the gce cloudprovider is removed.
91-
globalflag.Register(namedFlagSets.FlagSet("generic"), "cloud-provider-gce-lb-src-cidrs")
90+
91+
if flag.CommandLine.Lookup("cloud-provider-gce-lb-src-cidrs") != nil {
92+
// hoist this flag from the global flagset to preserve the commandline until
93+
// the gce cloudprovider is removed.
94+
globalflag.Register(namedFlagSets.FlagSet("generic"), "cloud-provider-gce-lb-src-cidrs")
95+
}
9296
for _, f := range namedFlagSets.FlagSets {
9397
fs.AddFlagSet(f)
9498
}

0 commit comments

Comments
 (0)