Skip to content

Commit 52f818d

Browse files
fix: Add default values for namespaces to match usage descriptions (#2128)
* fix: Add default values for namespaces to match usage descriptions Signed-off-by: pengfei4.li <pengfei4.li@ly.com> * fix: remove incorrect cache settings Signed-off-by: pengfei4.li <pengfei4.li@ly.com> --------- Signed-off-by: pengfei4.li <pengfei4.li@ly.com> Co-authored-by: pengfei4.li <pengfei4.li@ly.com>
1 parent 4bc6e89 commit 52f818d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

cmd/operator/controller/start.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func NewStartCommand() *cobra.Command {
124124
}
125125

126126
command.Flags().IntVar(&controllerThreads, "controller-threads", 10, "Number of worker threads used by the SparkApplication controller.")
127-
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{}, "The Kubernetes namespace to manage. Will manage custom resource objects of the managed CRD types for the whole cluster if unset.")
127+
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{""}, "The Kubernetes namespace to manage. Will manage custom resource objects of the managed CRD types for the whole cluster if unset.")
128128
command.Flags().DurationVar(&cacheSyncTimeout, "cache-sync-timeout", 30*time.Second, "Informer cache sync timeout.")
129129

130130
command.Flags().BoolVar(&enableBatchScheduler, "enable-batch-scheduler", false, "Enable batch schedulers.")
@@ -300,9 +300,7 @@ func newTLSOptions() []func(c *tls.Config) {
300300
// newCacheOptions creates and returns a cache.Options instance configured with default namespaces and object caching settings.
301301
func newCacheOptions() cache.Options {
302302
defaultNamespaces := make(map[string]cache.Config)
303-
if util.ContainsString(namespaces, cache.AllNamespaces) {
304-
defaultNamespaces[cache.AllNamespaces] = cache.Config{}
305-
} else {
303+
if !util.ContainsString(namespaces, cache.AllNamespaces) {
306304
for _, ns := range namespaces {
307305
defaultNamespaces[ns] = cache.Config{}
308306
}

cmd/operator/webhook/start.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func NewStartCommand() *cobra.Command {
130130
}
131131

132132
command.Flags().IntVar(&controllerThreads, "controller-threads", 10, "Number of worker threads used by the SparkApplication controller.")
133-
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{"default"}, "The Kubernetes namespace to manage. Will manage custom resource objects of the managed CRD types for the whole cluster if unset.")
133+
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{""}, "The Kubernetes namespace to manage. Will manage custom resource objects of the managed CRD types for the whole cluster if unset.")
134134
command.Flags().StringVar(&labelSelectorFilter, "label-selector-filter", "", "A comma-separated list of key=value, or key labels to filter resources during watch and list based on the specified labels.")
135135
command.Flags().DurationVar(&cacheSyncTimeout, "cache-sync-timeout", 30*time.Second, "Informer cache sync timeout.")
136136

@@ -368,9 +368,7 @@ func newTLSOptions() []func(c *tls.Config) {
368368
// newCacheOptions creates and returns a cache.Options instance configured with default namespaces and object caching settings.
369369
func newCacheOptions() cache.Options {
370370
defaultNamespaces := make(map[string]cache.Config)
371-
if util.ContainsString(namespaces, cache.AllNamespaces) {
372-
defaultNamespaces[cache.AllNamespaces] = cache.Config{}
373-
} else {
371+
if !util.ContainsString(namespaces, cache.AllNamespaces) {
374372
for _, ns := range namespaces {
375373
defaultNamespaces[ns] = cache.Config{}
376374
}

0 commit comments

Comments
 (0)