Skip to content

Commit

Permalink
Address @nikhiljindal's comments
Browse files Browse the repository at this point in the history
- Removed lower/upper bounds on retry delay
- Improved empty kubeconfig path error message
  • Loading branch information
tsandall committed May 27, 2017
1 parent 9865c86 commit 5847b7d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions federation/plugin/pkg/admission/schedulingpolicy/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ const (
configKey = "schedulingPolicy"
policyConfigMapNamespace = "kube-federation-scheduling-policy"

// Lower and upper bounds on policy engine query retry delays. The actual
// Default backoff delay for policy engine query retries. The actual
// backoff implementation is handled by k8s.io/apiserver/pkg/util/webhook.
// The defaultRetryBackoff is used if the admission controller
// configuration does not specify one.
minRetryBackoff = time.Millisecond
maxRetryBackoff = time.Second * 60
// If the admission controller config file does not specify a backoff, this
// one is used.
defaultRetryBackoff = time.Millisecond * 100
)

Expand Down Expand Up @@ -193,17 +191,18 @@ func loadConfig(file io.Reader) (*admissionConfig, error) {
}

if len(cfg.Kubeconfig) == 0 {
return nil, fmt.Errorf("kubeconfig must specify path")
return nil, fmt.Errorf("kubeconfig path must not be empty")
}

if cfg.RetryBackoff == 0 {
cfg.RetryBackoff = defaultRetryBackoff
} else {
// Scale up value from config (which is unmarshalled as ns).
cfg.RetryBackoff *= time.Millisecond
if cfg.RetryBackoff < minRetryBackoff || cfg.RetryBackoff > maxRetryBackoff {
return nil, fmt.Errorf("retryBackoff must be between %v and %v but got %v", minRetryBackoff, maxRetryBackoff, cfg.RetryBackoff)
}
}

if cfg.RetryBackoff.Nanoseconds() < 0 {
return nil, fmt.Errorf("retryBackoff must not be negative")
}

return &cfg, nil
Expand Down

0 comments on commit 5847b7d

Please sign in to comment.