Skip to content

Commit

Permalink
apf: handle error from PollImmediateUntil
Browse files Browse the repository at this point in the history
We should not attempt creation of mandatory objects if ensuring
the suggested configuration resulted in an error.
We rely on the presence of the "exempt" priority level configuration
object in the cluster to indicate whether we should ensure
suggested configuration.
  • Loading branch information
tkashem committed Mar 24, 2021
1 parent 939168c commit 1e316e6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/registry/flowcontrol/rest/storage_flowcontrol.go
Expand Up @@ -100,7 +100,7 @@ func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStart
flowcontrolClientSet := flowcontrolclient.NewForConfigOrDie(hookContext.LoopbackClientConfig)
go func() {
const retryCreatingSuggestedSettingsInterval = time.Second
_ = wait.PollImmediateUntil(
err := wait.PollImmediateUntil(
retryCreatingSuggestedSettingsInterval,
func() (bool, error) {
should, err := shouldEnsureSuggested(flowcontrolClientSet)
Expand All @@ -122,14 +122,25 @@ func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStart
return true, nil
},
hookContext.StopCh)
if err != nil {
klog.ErrorS(err, "Ensuring suggested configuration failed")

// We should not attempt creation of mandatory objects if ensuring the suggested
// configuration resulted in an error.
// This only happens when the stop channel is closed.
// We rely on the presence of the "exempt" priority level configuration object in the cluster
// to indicate whether we should ensure suggested configuration.
return
}

const retryCreatingMandatorySettingsInterval = time.Minute
_ = wait.PollImmediateUntil(
retryCreatingMandatorySettingsInterval,
func() (bool, error) {
if err := upgrade(
flowcontrolClientSet,
flowcontrolbootstrap.MandatoryFlowSchemas,
// Note: the "exempt" priority-level is supposed tobe the last item in the pre-defined
// Note: the "exempt" priority-level is supposed to be the last item in the pre-defined
// list, so that a crash in the midst of the first kube-apiserver startup does not prevent
// the full initial set of objects from being created.
flowcontrolbootstrap.MandatoryPriorityLevelConfigurations,
Expand Down

0 comments on commit 1e316e6

Please sign in to comment.