diff --git a/examples/deploy/addon/helloworld-helm/kustomization.yaml b/examples/deploy/addon/helloworld-helm/kustomization.yaml index bfe217d67..7d42707ac 100644 --- a/examples/deploy/addon/helloworld-helm/kustomization.yaml +++ b/examples/deploy/addon/helloworld-helm/kustomization.yaml @@ -1,7 +1,6 @@ namespace: open-cluster-management resources: -- resources/addon_deployment_config.yaml - resources/cluster_role.yaml - resources/cluster_role_binding.yaml - resources/service_account.yaml diff --git a/examples/deploy/addon/helloworld-helm/resources/addon_deployment_config.yaml b/examples/deploy/addon/helloworld-helm/resources/addon_deployment_config.yaml deleted file mode 100644 index fd5088372..000000000 --- a/examples/deploy/addon/helloworld-helm/resources/addon_deployment_config.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: addon.open-cluster-management.io/v1alpha1 -kind: AddOnDeploymentConfig -metadata: - name: helloworldhelm-config -spec: - agentInstallNamespace: open-cluster-management-agent-addon diff --git a/examples/deploy/addon/helloworld-helm/resources/helloworld_helm_clustermanagementaddon.yaml b/examples/deploy/addon/helloworld-helm/resources/helloworld_helm_clustermanagementaddon.yaml index 8bb30a314..5a24d7310 100644 --- a/examples/deploy/addon/helloworld-helm/resources/helloworld_helm_clustermanagementaddon.yaml +++ b/examples/deploy/addon/helloworld-helm/resources/helloworld_helm_clustermanagementaddon.yaml @@ -9,7 +9,4 @@ spec: supportedConfigs: - group: addon.open-cluster-management.io resource: addondeploymentconfigs - defaultConfig: - name: helloworldhelm-config - namespace: open-cluster-management - resource: configmaps diff --git a/pkg/addonfactory/helm_agentaddon.go b/pkg/addonfactory/helm_agentaddon.go index 69995c189..e010d2073 100644 --- a/pkg/addonfactory/helm_agentaddon.go +++ b/pkg/addonfactory/helm_agentaddon.go @@ -226,11 +226,14 @@ func (a *HelmAgentAddon) getValueAgentInstallNamespace(addon *addonapiv1alpha1.M if a.agentInstallNamespace != nil { ns, err := a.agentInstallNamespace(addon) if err != nil { - klog.Errorf("failed to get agentInstallNamespace from addon %s. err:%v", addon.Name, err) + klog.Errorf("failed to get agentInstallNamespace from addon %s. err: %v", addon.Name, err) return "", err } if len(ns) > 0 { installNamespace = ns + } else { + klog.InfoS("Namespace for addon returned by agent install namespace func is empty", + "addonNamespace", addon.Namespace, "addonName", addon) } } return installNamespace, nil diff --git a/pkg/addonfactory/template_agentaddon.go b/pkg/addonfactory/template_agentaddon.go index fd771aa16..5772fe95c 100644 --- a/pkg/addonfactory/template_agentaddon.go +++ b/pkg/addonfactory/template_agentaddon.go @@ -135,6 +135,9 @@ func (a *TemplateAgentAddon) getBuiltinValues( } if len(ns) > 0 { installNamespace = ns + } else { + klog.InfoS("Namespace for addon returned by agent install namespace func is empty", + "addonNamespace", addon.Namespace, "addonName", addon) } } builtinValues.AddonInstallNamespace = installNamespace diff --git a/pkg/addonmanager/controllers/registration/controller.go b/pkg/addonmanager/controllers/registration/controller.go index 4ca3551c0..db9bef351 100644 --- a/pkg/addonmanager/controllers/registration/controller.go +++ b/pkg/addonmanager/controllers/registration/controller.go @@ -170,8 +170,8 @@ func (c *addonRegistrationController) sync(ctx context.Context, syncCtx factory. if len(ns) > 0 { managedClusterAddonCopy.Status.Namespace = ns } else { - klog.Infof("Namespace for addon %s/%s returned by agent install namespace func is empty", - managedClusterAddonCopy.Namespace, managedClusterAddonCopy.Name) + klog.InfoS("Namespace for addon returned by agent install namespace func is empty", + "addonNamespace", managedClusterAddonCopy.Namespace, "addonName", managedClusterAddonCopy.Name) } } diff --git a/pkg/utils/addon_config.go b/pkg/utils/addon_config.go index 50f15ac1d..eaa91a9f0 100644 --- a/pkg/utils/addon_config.go +++ b/pkg/utils/addon_config.go @@ -46,8 +46,16 @@ func AgentInstallNamespaceFromDeploymentConfigFunc( if err != nil { return "", fmt.Errorf("failed to get deployment config for addon %s: %v", addon.Name, err) } + + // For now, we have no way of knowing if the addon depleoyment config is not configured, or + // is configured but not yet been added to the managedclusteraddon status config references, + // we expect no error will be returned when the addon deployment config is not configured + // so we can use the default namespace. + // TODO: Find a way to distinguish between the above two cases if config == nil { - return "", fmt.Errorf("failed to get deployment config for addon %s", addon.Name) + klog.InfoS("Addon deployment config is nil, return an empty string for agent install namespace", + "addonNamespace", addon.Namespace, "addonName", addon.Name) + return "", nil } return config.Spec.AgentInstallNamespace, nil