diff --git a/cli/cmd/install.go b/cli/cmd/install.go index f8173b91a8..8d31b7f9c2 100644 --- a/cli/cmd/install.go +++ b/cli/cmd/install.go @@ -205,7 +205,6 @@ func validateUserInputProfiles(tier common.OdigosTier) { } func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration { - fullIgnoredNamespaces := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredNamespaces, consts.SystemNamespaces) fullIgnoredContainers := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredContainers, consts.IgnoredContainers) selectedProfiles := []common.ProfileName{} @@ -218,7 +217,7 @@ func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration ConfigVersion: 1, // config version starts at 1 and incremented on every config change TelemetryEnabled: telemetryEnabled, OpenshiftEnabled: openshiftEnabled, - IgnoredNamespaces: fullIgnoredNamespaces, + IgnoredNamespaces: userInputIgnoredNamespaces, IgnoredContainers: fullIgnoredContainers, SkipWebhookIssuerCreation: skipWebhookIssuerCreation, Psp: psp, @@ -254,7 +253,7 @@ func init() { installCmd.Flags().StringVar(&autoScalerImage, "autoscaler-image", "keyval/odigos-autoscaler", "autoscaler container image name") installCmd.Flags().StringVar(&imagePrefix, "image-prefix", "", "prefix for all container images. used when your cluster doesn't have access to docker hub") installCmd.Flags().BoolVar(&psp, "psp", false, "enable pod security policy") - installCmd.Flags().StringSliceVar(&userInputIgnoredNamespaces, "ignore-namespace", consts.SystemNamespaces, "namespaces not to show in odigos ui") + installCmd.Flags().StringSliceVar(&userInputIgnoredNamespaces, "ignore-namespace", consts.DefaultIgnoredNamespaces, "namespaces not to show in odigos ui") installCmd.Flags().StringSliceVar(&userInputIgnoredContainers, "ignore-container", consts.IgnoredContainers, "container names to exclude from instrumentation (useful for sidecar container)") installCmd.Flags().StringSliceVar(&userInputInstallProfiles, "profile", []string{}, "install preset profiles with a specific configuration") diff --git a/cli/cmd/upgrade.go b/cli/cmd/upgrade.go index 11331a78fb..89df0001b6 100644 --- a/cli/cmd/upgrade.go +++ b/cli/cmd/upgrade.go @@ -12,8 +12,6 @@ import ( "github.com/odigos-io/odigos/cli/cmd/resources/odigospro" cmdcontext "github.com/odigos-io/odigos/cli/pkg/cmd_context" "github.com/odigos-io/odigos/cli/pkg/confirm" - "github.com/odigos-io/odigos/common/consts" - "github.com/odigos-io/odigos/common/utils" k8sconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts" "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -107,9 +105,6 @@ and apply any required migrations and adaptations.`, // update the config on upgrade config.ConfigVersion += 1 - // make sure the current system namespaces is in the ignored in config - config.IgnoredNamespaces = utils.MergeDefaultIgnoreWithUserInput(config.IgnoredNamespaces, consts.SystemNamespaces) - currentTier, err := odigospro.GetCurrentOdigosTier(ctx, client, ns) if err != nil { fmt.Println("Odigos cloud login failed - unable to read the current Odigos tier.") diff --git a/common/consts/consts.go b/common/consts/consts.go index 62c6a61521..64e611739f 100644 --- a/common/consts/consts.go +++ b/common/consts/consts.go @@ -43,6 +43,6 @@ var ( ) var ( - SystemNamespaces = []string{DefaultOdigosNamespace, "kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"} - IgnoredContainers = []string{"istio-proxy", "vault-agent", "filebeat", "linkerd-proxy", "fluentd", "akeyless-init"} + DefaultIgnoredNamespaces = []string{"kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"} + IgnoredContainers = []string{"istio-proxy", "vault-agent", "filebeat", "linkerd-proxy", "fluentd", "akeyless-init"} ) diff --git a/scheduler/controllers/odigosconfig/odigosconfig_controller.go b/scheduler/controllers/odigosconfig/odigosconfig_controller.go index 69d1507249..5b127ea1df 100644 --- a/scheduler/controllers/odigosconfig/odigosconfig_controller.go +++ b/scheduler/controllers/odigosconfig/odigosconfig_controller.go @@ -27,6 +27,10 @@ func (r *odigosConfigController) Reconcile(ctx context.Context, _ ctrl.Request) return ctrl.Result{}, err } + // make sure the default ignored namespaces are always present + odigosConfig.IgnoredNamespaces = mergeIgnoredItemLists(odigosConfig.IgnoredNamespaces, consts.DefaultIgnoredNamespaces) + odigosConfig.IgnoredNamespaces = append(odigosConfig.IgnoredNamespaces, env.GetCurrentNamespace()) + err = r.persistEffectiveConfig(ctx, odigosConfig) if err != nil { return ctrl.Result{}, err diff --git a/scheduler/controllers/odigosconfig/utils.go b/scheduler/controllers/odigosconfig/utils.go new file mode 100644 index 0000000000..ae45e0222e --- /dev/null +++ b/scheduler/controllers/odigosconfig/utils.go @@ -0,0 +1,20 @@ +package odigosconfig + +func mergeIgnoredItemLists(l1 []string, l2 []string) []string { + + merged := map[string]struct{}{} + + for _, i := range l1 { + merged[i] = struct{}{} + } + for _, i := range l2 { + merged[i] = struct{}{} + } + + mergedList := make([]string, 0, len(merged)) + for i := range merged { + mergedList = append(mergedList, i) + } + + return mergedList +}