Skip to content

Commit d580d6e

Browse files
authored
Merge pull request #460 from gianlucam76/pullmode
(bug) fix combination agent in mgmt cluster and pullmode cluster
2 parents 4ae99c2 + 29c99c9 commit d580d6e

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

controllers/classifier_deployer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func updateSecretWithAccessManagementKubeconfig(ctx context.Context, c client.Cl
434434
func deployCRDs(ctx context.Context, clusterNamespace, clusterName, classifierName string,
435435
clusterType libsveltosv1beta1.ClusterType, isPullMode bool, logger logr.Logger) error {
436436

437-
if getAgentInMgmtCluster() {
437+
if getAgentInMgmtCluster() && !isPullMode {
438438
// CRDs must be deployed alongside the agent. Since the management cluster already contains these CRDs,
439439
// this operation is a no-op if the agent is deployed there.
440440
return nil
@@ -616,7 +616,7 @@ func deployClassifierInCluster(ctx context.Context, c client.Client,
616616
return err
617617
}
618618

619-
if getAgentInMgmtCluster() {
619+
if getAgentInMgmtCluster() && !isPullMode {
620620
// If sveltos-agent is deployed in the management cluster, Classifier instance
621621
// does not need to be deployed in the managed cluster. So return here
622622
return nil
@@ -1579,12 +1579,18 @@ func deploySveltosAgent(ctx context.Context, c client.Client, clusterNamespace,
15791579
}
15801580

15811581
// Deploy SveltosAgent
1582-
if startInMgmtCluster {
1582+
if isPullMode {
1583+
err = deploySveltosAgentInManagedCluster(ctx, nil, clusterNamespace,
1584+
clusterName, classifierName, "do-not-send-reports", clusterType, patches, true, logger)
1585+
if err != nil {
1586+
return err
1587+
}
1588+
} else if startInMgmtCluster {
15831589
// Use management cluster restConfig
15841590
restConfig := getManagementClusterConfig()
15851591
return deploySveltosAgentInManagementCluster(ctx, restConfig, c, clusterNamespace, clusterName,
15861592
classifierName, "do-not-send-reports", clusterType, patches, logger)
1587-
} else if !isPullMode {
1593+
} else {
15881594
// Use managed cluster restConfig
15891595
remoteRestConfig, err := clusterproxy.GetKubernetesRestConfig(ctx, c, clusterNamespace, clusterName,
15901596
"", "", clusterType, logger)
@@ -1602,12 +1608,6 @@ func deploySveltosAgent(ctx context.Context, c client.Client, clusterNamespace,
16021608
if err != nil {
16031609
return err
16041610
}
1605-
} else {
1606-
err = deploySveltosAgentInManagedCluster(ctx, nil, clusterNamespace,
1607-
clusterName, classifierName, "do-not-send-reports", clusterType, patches, true, logger)
1608-
if err != nil {
1609-
return err
1610-
}
16111611
}
16121612
return nil
16131613
}

0 commit comments

Comments
 (0)