From 37f449f427c8ee6d471959e73dc6d2a054cb6519 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Tue, 13 Oct 2026 10:17:33 +0300 Subject: [PATCH 1/3] Don't use on-cluster manifest as config base on redeployments --- cmd/deploy.go | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 1fc3cfa..29fb9f2 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -20,7 +20,6 @@ import ( "github.com/stackrox/roxie/internal/env" "github.com/stackrox/roxie/internal/helpers" "github.com/stackrox/roxie/internal/imagetag" - "github.com/stackrox/roxie/internal/k8s" log "github.com/stackrox/roxie/internal/logger" "github.com/stackrox/roxie/internal/manifest" "github.com/stackrox/roxie/internal/roxieenv" @@ -235,14 +234,9 @@ func runDeploy(cmd *cobra.Command, args []string) error { return err } - // Cluster-config retrieval happens before the full config (and thus the configured deploy - // wait timeouts) is assembled, so give it its own short bounded context. - setupCtx, setupCancel := context.WithTimeout(context.Background(), 10*time.Minute) - defer setupCancel() + clusterConfig := deployer.DefaultConfig() - clusterConfig := retrieveClusterConfigForComponents(setupCtx, components) - - deploySettings, err := assembleConfigForCommand(clusterConfig, deploySettingsFromArgs, skipUserConfig) + deploySettings, err := assembleConfigForCommand(&clusterConfig, deploySettingsFromArgs, skipUserConfig) if err != nil { return err } @@ -402,30 +396,6 @@ func validateContainerizedCredentials(registry string, clusterType types.Cluster return nil } -func retrieveClusterConfigForComponents( - ctx context.Context, - components component.Component, -) *deployer.Config { - clusterManifest, err := manifest.LoadManifestSecret(ctx) - if err != nil { - if errors.Is(err, k8s.ErrResourceNotFound) { - log.Dim("No existing manifest found on cluster, starting from defaults") - } else { - log.Warningf("Failed to load manifest from cluster: %v", err) - } - return nil // Let's try to continue without manifest - } - - if components == component.SecuredCluster && clusterManifest.Config.SecuredCluster.Spec != nil { - // Reusing these fields from the config stored on the cluster would cause problems - // during repeating sensor deploy & teardown cycles. - delete(clusterManifest.Config.SecuredCluster.Spec, "clusterName") - delete(clusterManifest.Config.SecuredCluster.Spec, "centralEndpoint") - } - - return &clusterManifest.Config -} - func configureConfig(components component.Component, deploySettings *deployer.Config) error { if deploySettings.Roxie.ClusterType == "" { clusterType := env.GetAutoDetectedClusterType() From 44ddb9a69cdf0fa28b7eb1b76350a22255ffea3f Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Tue, 13 Oct 2026 10:19:59 +0300 Subject: [PATCH 2/3] (CI trigger) From 13fb91e66e7a1421dd197b6887f69376b3e8bba8 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Tue, 13 Oct 2026 11:53:41 +0300 Subject: [PATCH 3/3] Improve manifest updating logic --- cmd/deploy.go | 66 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 29fb9f2..bbc6594 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -20,6 +20,7 @@ import ( "github.com/stackrox/roxie/internal/env" "github.com/stackrox/roxie/internal/helpers" "github.com/stackrox/roxie/internal/imagetag" + "github.com/stackrox/roxie/internal/k8s" log "github.com/stackrox/roxie/internal/logger" "github.com/stackrox/roxie/internal/manifest" "github.com/stackrox/roxie/internal/roxieenv" @@ -339,13 +340,9 @@ func runDeploy(cmd *cobra.Command, args []string) error { } if !dryRun { - roxieEnv := roxieenv.AssembleRoxieEnvironment(d.GetCentralDeploymentInfo()) - m := manifest.RoxieManifest{ - RoxieEnvironment: roxieEnv, - Config: deploySettings, - } - if err := manifest.CreateManifestSecretOnCluster(ctx, m); err != nil { - log.Warningf("Failed to save roxie manifest: %v", err) + if err := updateManifest(ctx, d, components, deploySettings); err != nil { + log.Warningf("Updating roxie manifest failed: %v", err) + // Keep going. } } @@ -577,3 +574,58 @@ func generateClusterName() string { return fmt.Sprintf("sensor-%d", randInt) } + +func updateManifest(ctx context.Context, d *deployer.Deployer, components component.Component, deploySettings deployer.Config) error { + newManifest := manifest.RoxieManifest{} + + currentManifest, err := manifest.LoadManifestSecret(ctx) + if err != nil { + if errors.Is(err, k8s.ErrResourceNotFound) { + // No manifest on the cluster, probably due to an isolated SecuredCluster deployment with roxie + // on a cluster without a (roxie-deployed) central. + // In this case we don't need to merge anything, we will just create a new manifest with + // current deploySettings. + log.Dim("No existing roxie manifest found on cluster, starting from defaults") + } else { + log.Warningf("Failed to load roxie manifest from cluster: %v", err) + log.Warning("Skipping updating roxie manifest") + return err + } + } + + // Manifest updating logic heavily depends on the components. + switch components { + case component.Both, component.All, component.Central: + // Includes central, create roxie manifest from scratch. + roxieEnv := roxieenv.AssembleRoxieEnvironment(d.GetCentralDeploymentInfo()) + newManifest.RoxieEnvironment = roxieEnv + newManifest.Config = deploySettings + case component.SecuredCluster: + // If a previous manifest exists on cluster, update it to include the SecuredCluster settings. + if currentManifest == nil { + newManifest.Config = deploySettings + } else { + log.Dim("Found existing roxie manifest on cluster, updating only SecuredCluster deployment settings") + newManifest = *currentManifest + newManifest.Config.SecuredCluster = deploySettings.SecuredCluster + } + case component.Operator: + // If a previous manifest exists on cluster, update it to include the Operator settings. + if currentManifest == nil { + newManifest.Config = deploySettings + } else { + log.Dim("Found existing roxie manifest on cluster, updating only Operator deployment settings") + newManifest = *currentManifest + newManifest.Config.Operator = deploySettings.Operator + } + case component.AddOns: + // Nothing to write in this case. + return nil + } + + if err := manifest.CreateManifestSecretOnCluster(ctx, newManifest); err != nil { + log.Warningf("Failed to save roxie manifest: %v", err) + } + + return nil +}