From 29c99c98dead202b2cdeb4a14b53b0bc14d449e2 Mon Sep 17 00:00:00 2001 From: Gianluca Mardente Date: Wed, 8 Apr 2026 21:54:40 +0200 Subject: [PATCH] (bug) fix combination agent in mgmt cluster and pullmode cluster --- controllers/classifier_deployer.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/controllers/classifier_deployer.go b/controllers/classifier_deployer.go index e875130..9b902e2 100644 --- a/controllers/classifier_deployer.go +++ b/controllers/classifier_deployer.go @@ -434,7 +434,7 @@ func updateSecretWithAccessManagementKubeconfig(ctx context.Context, c client.Cl func deployCRDs(ctx context.Context, clusterNamespace, clusterName, classifierName string, clusterType libsveltosv1beta1.ClusterType, isPullMode bool, logger logr.Logger) error { - if getAgentInMgmtCluster() { + if getAgentInMgmtCluster() && !isPullMode { // CRDs must be deployed alongside the agent. Since the management cluster already contains these CRDs, // this operation is a no-op if the agent is deployed there. return nil @@ -616,7 +616,7 @@ func deployClassifierInCluster(ctx context.Context, c client.Client, return err } - if getAgentInMgmtCluster() { + if getAgentInMgmtCluster() && !isPullMode { // If sveltos-agent is deployed in the management cluster, Classifier instance // does not need to be deployed in the managed cluster. So return here return nil @@ -1579,12 +1579,18 @@ func deploySveltosAgent(ctx context.Context, c client.Client, clusterNamespace, } // Deploy SveltosAgent - if startInMgmtCluster { + if isPullMode { + err = deploySveltosAgentInManagedCluster(ctx, nil, clusterNamespace, + clusterName, classifierName, "do-not-send-reports", clusterType, patches, true, logger) + if err != nil { + return err + } + } else if startInMgmtCluster { // Use management cluster restConfig restConfig := getManagementClusterConfig() return deploySveltosAgentInManagementCluster(ctx, restConfig, c, clusterNamespace, clusterName, classifierName, "do-not-send-reports", clusterType, patches, logger) - } else if !isPullMode { + } else { // Use managed cluster restConfig remoteRestConfig, err := clusterproxy.GetKubernetesRestConfig(ctx, c, clusterNamespace, clusterName, "", "", clusterType, logger) @@ -1602,12 +1608,6 @@ func deploySveltosAgent(ctx context.Context, c client.Client, clusterNamespace, if err != nil { return err } - } else { - err = deploySveltosAgentInManagedCluster(ctx, nil, clusterNamespace, - clusterName, classifierName, "do-not-send-reports", clusterType, patches, true, logger) - if err != nil { - return err - } } return nil }