Skip to content

Commit

Permalink
set defualt queue size when env is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamMN committed Feb 13, 2025
1 parent e592019 commit c5e0a51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/aro/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,14 @@ func portal(ctx context.Context, log *logrus.Entry, auditLog *logrus.Entry) erro

log.Printf("listening %s", address)

size, err := strconv.Atoi(os.Getenv(env.OtelAuditQueueSize))
if err != nil {
return err
var size int
if err := env.ValidateVars(env.OtelAuditQueueSize); err != nil {
size = 4000
} else {
size, err = strconv.Atoi(os.Getenv(env.OtelAuditQueueSize))
if err != nil {
return err
}
}

outelAuditClient, err := audit.NewOtelAuditClient(size, _env.IsLocalDevelopmentMode())
Expand Down
1 change: 0 additions & 1 deletion cmd/aro/rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func rp(ctx context.Context, log, auditLog *logrus.Entry) error {
"MDM_NAMESPACE",
"MSI_RP_ENDPOINT",
env.OIDCStorageAccountName,
env.OtelAuditQueueSize,
}

if _, found := os.LookupEnv("PULL_SECRET"); found {
Expand Down
2 changes: 2 additions & 0 deletions pkg/env/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (d *dev) AROOperatorImage() string {
return fmt.Sprintf("%s/aro:%s", d.ACRDomain(), version.GitCommit)
}

// OtelAuditQueueSize returns the size of the audit queue for the OTel audit.
// In development environment this size is set to zero as we create noop connection to audit server.
func (d *dev) OtelAuditQueueSize() (int, error) {
return 0, nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/env/prod.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ func (p *prod) OIDCKeyBitSize() int {
return 4096
}

// OtelAuditQueueSize returns the size of the otel audit queue.
// If the OTEL_AUDIT_QUEUE_SIZE environment variable is not set, it returns the default value of 4000.
func (p *prod) OtelAuditQueueSize() (int, error) {
if err := ValidateVars(OtelAuditQueueSize); err != nil {
return 4000, nil
}
return strconv.Atoi(os.Getenv(OtelAuditQueueSize))
}

Expand Down

0 comments on commit c5e0a51

Please sign in to comment.