From 41804861b522776fb642c9dffd0e5beb059c5532 Mon Sep 17 00:00:00 2001 From: Vlad Bologa Date: Wed, 11 Nov 2026 15:45:13 +0100 Subject: [PATCH 1/3] Configurable CRS generation attempts --- cmd/deploy_test.go | 12 ++++++++++++ internal/deployer/config.go | 10 ++++++++++ internal/deployer/crs.go | 4 ++-- internal/deployer/deployer.go | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cmd/deploy_test.go b/cmd/deploy_test.go index a8130eed..be35d5b7 100644 --- a/cmd/deploy_test.go +++ b/cmd/deploy_test.go @@ -222,6 +222,18 @@ central: }, }, + { + name: "config file sets crs attempts", + config: ` +securedCluster: + crsAttempts: 5 +`, + args: []string{"--config", configFilePath}, + assert: func(t *testing.T, cfg deployer.Config) { + assert.Equal(t, uint(5), cfg.SecuredCluster.CRSAttempts, "SecuredCluster.CRSAttempts mismatch") + }, + }, + { name: "flags can override earlier specified config file", config: ` diff --git a/internal/deployer/config.go b/internal/deployer/config.go index fdaf3ef2..d444d45b 100644 --- a/internal/deployer/config.go +++ b/internal/deployer/config.go @@ -431,6 +431,7 @@ type SecuredClusterConfig struct { EarlyReadiness *bool `yaml:"earlyReadiness,omitempty"` Metadata CRMetadata `yaml:"metadata,omitempty"` Spec map[string]interface{} `yaml:"spec,omitempty"` + CRSAttempts uint `yaml:"crsAttempts,omitempty"` } func (s *SecuredClusterConfig) EarlyReadinessEnabled() bool { @@ -478,6 +479,15 @@ func (s *SecuredClusterConfig) GetWaitConfig() WaitConfig { } } +// CRSAttemptCount returns the total number of attempts for generating a CRS, +// including the first try. An unset value (0) defaults to DefaultCRSAttempts. +func (s *SecuredClusterConfig) CRSAttemptCount() uint { + if s.CRSAttempts == 0 { + return DefaultCRSAttempts + } + return s.CRSAttempts +} + // ConfigureSpec applies feature flags and the central endpoint to the SecuredCluster spec. func (s *SecuredClusterConfig) ConfigureSpec(roxieConfig *RoxieConfig, centralConfig *CentralConfig) error { envVarsPath := []string{"customize", "envVars"} diff --git a/internal/deployer/crs.go b/internal/deployer/crs.go index 6938ff97..72a56d37 100644 --- a/internal/deployer/crs.go +++ b/internal/deployer/crs.go @@ -49,7 +49,7 @@ type crsGenResponse struct { // generateCRS is a retrying wrapper on top of generateCRSOnce. func (d *Deployer) generateCRS(ctx context.Context, clusterName string) (string, error) { - const maxAttempts = 20 + maxAttempts := d.config.SecuredCluster.CRSAttemptCount() const retryWaitTime = 10 * time.Second client, err := d.centralHTTPClient() @@ -58,7 +58,7 @@ func (d *Deployer) generateCRS(ctx context.Context, clusterName string) (string, } var lastErr error - for attempt := 1; attempt <= maxAttempts; attempt++ { + for attempt := uint(1); attempt <= maxAttempts; attempt++ { if attempt > 1 { log.Infof("Retrying CRS generation (attempt %d/%d) after %v...", attempt, maxAttempts, retryWaitTime) select { diff --git a/internal/deployer/deployer.go b/internal/deployer/deployer.go index 09d6384b..2c9d56a9 100644 --- a/internal/deployer/deployer.go +++ b/internal/deployer/deployer.go @@ -31,6 +31,7 @@ import ( var ( DefaultCentralWaitTimeout = 20 * time.Minute DefaultSecuredClusterWaitTimeout = 20 * time.Minute + DefaultCRSAttempts = uint(20) pauseReconcileAnnotationKey = "stackrox.io/pause-reconcile" From c2c66286d7af6fbd59054619cb57a98cabeb1642 Mon Sep 17 00:00:00 2001 From: Vlad Bologa Date: Wed, 11 Nov 2026 17:27:48 +0100 Subject: [PATCH 2/3] Apply code review suggestions --- cmd/deploy_test.go | 6 +++--- internal/deployer/config.go | 12 ++---------- internal/deployer/crs.go | 2 +- internal/deployer/deployer.go | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/cmd/deploy_test.go b/cmd/deploy_test.go index be35d5b7..1965c5b9 100644 --- a/cmd/deploy_test.go +++ b/cmd/deploy_test.go @@ -223,14 +223,14 @@ central: }, { - name: "config file sets crs attempts", + name: "config file sets crs issue attempts", config: ` securedCluster: - crsAttempts: 5 + crsIssueAttempts: 5 `, args: []string{"--config", configFilePath}, assert: func(t *testing.T, cfg deployer.Config) { - assert.Equal(t, uint(5), cfg.SecuredCluster.CRSAttempts, "SecuredCluster.CRSAttempts mismatch") + assert.Equal(t, uint(5), cfg.SecuredCluster.CRSIssueAttempts, "SecuredCluster.CRSIssueAttempts mismatch") }, }, diff --git a/internal/deployer/config.go b/internal/deployer/config.go index d444d45b..34c548c1 100644 --- a/internal/deployer/config.go +++ b/internal/deployer/config.go @@ -431,7 +431,7 @@ type SecuredClusterConfig struct { EarlyReadiness *bool `yaml:"earlyReadiness,omitempty"` Metadata CRMetadata `yaml:"metadata,omitempty"` Spec map[string]interface{} `yaml:"spec,omitempty"` - CRSAttempts uint `yaml:"crsAttempts,omitempty"` + CRSIssueAttempts uint `yaml:"crsIssueAttempts,omitempty"` } func (s *SecuredClusterConfig) EarlyReadinessEnabled() bool { @@ -451,6 +451,7 @@ func DefaultSecuredClusterConfig() SecuredClusterConfig { cfg.DeployTimeout = DefaultSecuredClusterWaitTimeout cfg.Namespace = "acs-sensor" cfg.EarlyReadiness = new(true) + cfg.CRSIssueAttempts = DefaultCRSIssueAttempts return cfg } @@ -479,15 +480,6 @@ func (s *SecuredClusterConfig) GetWaitConfig() WaitConfig { } } -// CRSAttemptCount returns the total number of attempts for generating a CRS, -// including the first try. An unset value (0) defaults to DefaultCRSAttempts. -func (s *SecuredClusterConfig) CRSAttemptCount() uint { - if s.CRSAttempts == 0 { - return DefaultCRSAttempts - } - return s.CRSAttempts -} - // ConfigureSpec applies feature flags and the central endpoint to the SecuredCluster spec. func (s *SecuredClusterConfig) ConfigureSpec(roxieConfig *RoxieConfig, centralConfig *CentralConfig) error { envVarsPath := []string{"customize", "envVars"} diff --git a/internal/deployer/crs.go b/internal/deployer/crs.go index 72a56d37..eff7e5e7 100644 --- a/internal/deployer/crs.go +++ b/internal/deployer/crs.go @@ -49,7 +49,7 @@ type crsGenResponse struct { // generateCRS is a retrying wrapper on top of generateCRSOnce. func (d *Deployer) generateCRS(ctx context.Context, clusterName string) (string, error) { - maxAttempts := d.config.SecuredCluster.CRSAttemptCount() + maxAttempts := d.config.SecuredCluster.CRSIssueAttempts const retryWaitTime = 10 * time.Second client, err := d.centralHTTPClient() diff --git a/internal/deployer/deployer.go b/internal/deployer/deployer.go index 2c9d56a9..68bcb7c6 100644 --- a/internal/deployer/deployer.go +++ b/internal/deployer/deployer.go @@ -31,7 +31,7 @@ import ( var ( DefaultCentralWaitTimeout = 20 * time.Minute DefaultSecuredClusterWaitTimeout = 20 * time.Minute - DefaultCRSAttempts = uint(20) + DefaultCRSIssueAttempts = uint(20) pauseReconcileAnnotationKey = "stackrox.io/pause-reconcile" From 5d256e1540a49b08a89c7030a83a2f72af50b40b Mon Sep 17 00:00:00 2001 From: Vlad Bologa Date: Tue, 17 Nov 2026 17:36:51 +0100 Subject: [PATCH 3/3] Rename CRSIssueAttempts to CRSIssueRetries --- cmd/deploy_test.go | 6 +++--- internal/deployer/config.go | 4 ++-- internal/deployer/crs.go | 2 +- internal/deployer/deployer.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/deploy_test.go b/cmd/deploy_test.go index 1965c5b9..afc6cda4 100644 --- a/cmd/deploy_test.go +++ b/cmd/deploy_test.go @@ -223,14 +223,14 @@ central: }, { - name: "config file sets crs issue attempts", + name: "config file sets crs issue retries", config: ` securedCluster: - crsIssueAttempts: 5 + crsIssueRetries: 5 `, args: []string{"--config", configFilePath}, assert: func(t *testing.T, cfg deployer.Config) { - assert.Equal(t, uint(5), cfg.SecuredCluster.CRSIssueAttempts, "SecuredCluster.CRSIssueAttempts mismatch") + assert.Equal(t, uint(5), cfg.SecuredCluster.CRSIssueRetries, "SecuredCluster.CRSIssueRetries mismatch") }, }, diff --git a/internal/deployer/config.go b/internal/deployer/config.go index 34c548c1..d1eba101 100644 --- a/internal/deployer/config.go +++ b/internal/deployer/config.go @@ -431,7 +431,7 @@ type SecuredClusterConfig struct { EarlyReadiness *bool `yaml:"earlyReadiness,omitempty"` Metadata CRMetadata `yaml:"metadata,omitempty"` Spec map[string]interface{} `yaml:"spec,omitempty"` - CRSIssueAttempts uint `yaml:"crsIssueAttempts,omitempty"` + CRSIssueRetries uint `yaml:"crsIssueRetries,omitempty"` } func (s *SecuredClusterConfig) EarlyReadinessEnabled() bool { @@ -451,7 +451,7 @@ func DefaultSecuredClusterConfig() SecuredClusterConfig { cfg.DeployTimeout = DefaultSecuredClusterWaitTimeout cfg.Namespace = "acs-sensor" cfg.EarlyReadiness = new(true) - cfg.CRSIssueAttempts = DefaultCRSIssueAttempts + cfg.CRSIssueRetries = DefaultCRSIssueRetries return cfg } diff --git a/internal/deployer/crs.go b/internal/deployer/crs.go index eff7e5e7..38a1b106 100644 --- a/internal/deployer/crs.go +++ b/internal/deployer/crs.go @@ -49,7 +49,7 @@ type crsGenResponse struct { // generateCRS is a retrying wrapper on top of generateCRSOnce. func (d *Deployer) generateCRS(ctx context.Context, clusterName string) (string, error) { - maxAttempts := d.config.SecuredCluster.CRSIssueAttempts + maxAttempts := d.config.SecuredCluster.CRSIssueRetries + 1 const retryWaitTime = 10 * time.Second client, err := d.centralHTTPClient() diff --git a/internal/deployer/deployer.go b/internal/deployer/deployer.go index 68bcb7c6..e5b75310 100644 --- a/internal/deployer/deployer.go +++ b/internal/deployer/deployer.go @@ -31,7 +31,7 @@ import ( var ( DefaultCentralWaitTimeout = 20 * time.Minute DefaultSecuredClusterWaitTimeout = 20 * time.Minute - DefaultCRSIssueAttempts = uint(20) + DefaultCRSIssueRetries = uint(20) pauseReconcileAnnotationKey = "stackrox.io/pause-reconcile"