Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ central:
},
},

{
name: "config file sets crs issue retries",
config: `
securedCluster:
crsIssueRetries: 5
`,
args: []string{"--config", configFilePath},
assert: func(t *testing.T, cfg deployer.Config) {
assert.Equal(t, uint(5), cfg.SecuredCluster.CRSIssueRetries, "SecuredCluster.CRSIssueRetries mismatch")
},
},

{
name: "flags can override earlier specified config file",
config: `
Expand Down
2 changes: 2 additions & 0 deletions internal/deployer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ type SecuredClusterConfig struct {
EarlyReadiness *bool `yaml:"earlyReadiness,omitempty"`
Metadata CRMetadata `yaml:"metadata,omitempty"`
Spec map[string]interface{} `yaml:"spec,omitempty"`
CRSIssueRetries uint `yaml:"crsIssueRetries,omitempty"`
Comment thread
vladbologa marked this conversation as resolved.
Resolved
}

func (s *SecuredClusterConfig) EarlyReadinessEnabled() bool {
Expand All @@ -450,6 +451,7 @@ func DefaultSecuredClusterConfig() SecuredClusterConfig {
cfg.DeployTimeout = DefaultSecuredClusterWaitTimeout
cfg.Namespace = "acs-sensor"
cfg.EarlyReadiness = new(true)
cfg.CRSIssueRetries = DefaultCRSIssueRetries
return cfg
}

Expand Down
4 changes: 2 additions & 2 deletions internal/deployer/crs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.CRSIssueRetries + 1
const retryWaitTime = 10 * time.Second

client, err := d.centralHTTPClient()
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
var (
DefaultCentralWaitTimeout = 20 * time.Minute
DefaultSecuredClusterWaitTimeout = 20 * time.Minute
DefaultCRSIssueRetries = uint(20)

pauseReconcileAnnotationKey = "stackrox.io/pause-reconcile"

Expand Down
Loading