Skip to content

Commit

Permalink
add a CLOUD_AUTH_REGISTRATION_TIMEOUT env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
steved committed Nov 1, 2023
1 parent ab2f5f0 commit b1ca64d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -30,6 +31,16 @@ import (
// +kubebuilder:scaffold:imports
)

var cloudAuthRegistrationTimeout = 30 * time.Second

func init() {
if cloudAuthRegistrationTimeoutEnv := os.Getenv("CLOUD_AUTH_REGISTRATION_TIMEOUT"); cloudAuthRegistrationTimeoutEnv != "" {
if duration, err := time.ParseDuration(cloudAuthRegistrationTimeoutEnv); err == nil {
cloudAuthRegistrationTimeout = duration
}
}
}

// Start creates a new controller manager, registers controllers, and starts
// their control loops for resource reconciliation.
func Start(cfg config.Controller) error {
Expand Down Expand Up @@ -67,10 +78,10 @@ func Start(cfg config.Controller) error {
return err
}

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), cloudAuthRegistrationTimeout)
defer cancel()

log.Info("Registering cloud auth providers")
log.Info(fmt.Sprintf("Registering cloud auth providers with %s timeout", cloudAuthRegistrationTimeout))
if err = credentials.LoadCloudProviders(ctx, log); err != nil {
return err
}
Expand Down

0 comments on commit b1ca64d

Please sign in to comment.