Skip to content

Commit

Permalink
operator: initialise default namespaces map config (#5424) (#5426)
Browse files Browse the repository at this point in the history
(cherry picked from commit 37c40cc)

Co-authored-by: William Dumont <[email protected]>
  • Loading branch information
tpaschalis and wildum authored Oct 10, 2023
1 parent 5c430a4 commit 2da3ffe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion component/loki/source/kubernetes_events/event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func (ctrl *eventController) runError(ctx context.Context) error {
}

defaultNamespaces := map[string]cache.Config{}
defaultNamespaces[ctrl.task.Namespace] = cache.Config{}
if ctrl.task.Namespace != "" {
defaultNamespaces[ctrl.task.Namespace] = cache.Config{}
}
opts := cache.Options{
Scheme: scheme,
DefaultNamespaces: defaultNamespaces,
Expand Down
2 changes: 2 additions & 0 deletions component/prometheus/operator/common/crdmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ func (c *crdManager) runInformers(restConfig *rest.Config, ctx context.Context)
return fmt.Errorf("building label selector: %w", err)
}
for _, ns := range c.args.Namespaces {
// TODO: This is going down an unnecessary extra step in the cache when `c.args.Namespaces` defaults to NamespaceAll.
// This code path should be simplified and support a scenario when len(c.args.Namespace) == 0.
defaultNamespaces := map[string]cache.Config{}
defaultNamespaces[ns] = cache.Config{}
opts := cache.Options{
Expand Down
5 changes: 4 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func (c *Config) registerFlags(f *flag.FlagSet) error {

c.Controller.WebhookServer = webhook.NewServer(webhookServerOptions)

c.Controller.Cache.DefaultNamespaces[namespace] = cache.Config{}
if namespace != "" {
c.Controller.Cache.DefaultNamespaces = map[string]cache.Config{}
c.Controller.Cache.DefaultNamespaces[namespace] = cache.Config{}
}

// Custom initial values for the endpoint names.
c.Controller.ReadinessEndpointName = "/-/ready"
Expand Down

0 comments on commit 2da3ffe

Please sign in to comment.