Skip to content

Commit 98fb7ec

Browse files
committed
(bug) Fix namespace propagation for sveltos-agent and sveltos-applier resources
When deploying sveltos-agent and sveltos-applier resources into a non-default Sveltos namespace, adjust namespace.
1 parent a54d843 commit 98fb7ec

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

controllers/classifier_deployer.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,12 +1672,18 @@ func deploySveltosAgentInManagementCluster(ctx context.Context, restConfig *rest
16721672
}
16731673

16741674
// updateResourceNamespace sets the namespace on a resource that requires it.
1675+
// For Namespace resources the metadata.name is updated (the namespace is its identity).
16751676
// For namespaced resources the object metadata namespace is updated.
16761677
// For ClusterRoleBinding the subjects are also patched: the resource is cluster-scoped so
16771678
// GetNamespace() returns "" and the plain SetNamespace call would not reach it, but each
16781679
// ServiceAccount subject still carries an explicit namespace that must match the actual
16791680
// location of the ServiceAccount.
16801681
func updateResourceNamespace(policy *unstructured.Unstructured, namespace string) error {
1682+
if policy.GetKind() == "Namespace" {
1683+
policy.SetName(namespace)
1684+
return nil
1685+
}
1686+
16811687
if policy.GetNamespace() != "" {
16821688
policy.SetNamespace(namespace)
16831689
}
@@ -1975,7 +1981,9 @@ func removeSveltosAgentFromManagementCluster(ctx context.Context,
19751981
return err
19761982
}
19771983

1978-
if policy.GetNamespace() != "" {
1984+
if policy.GetKind() == "Namespace" {
1985+
policy.SetName(getSveltosNamespace())
1986+
} else if policy.GetNamespace() != "" {
19791987
policy.SetNamespace(getSveltosNamespace())
19801988
}
19811989

0 commit comments

Comments
 (0)