make some rbac and scheduling post start hooks tolerate the apiserver

bootstrap delay caused by installing storage versions.
This commit is contained in:
Chao Xu
2020-02-17 14:19:32 -08:00
committed by Haowei Cai
parent 7218978716
commit 22452917c2
2 changed files with 25 additions and 7 deletions

View File

@@ -128,11 +128,16 @@ func AddSystemPriorityClasses() genericapiserver.PostStartHookFunc {
if err != nil {
if apierrors.IsNotFound(err) {
_, err := schedClientSet.PriorityClasses().Create(context.TODO(), pc, metav1.CreateOptions{})
if err != nil && !apierrors.IsAlreadyExists(err) {
return false, err
} else {
if err == nil || apierrors.IsAlreadyExists(err) {
klog.Infof("created PriorityClass %s with value %v", pc.Name, pc.Value)
continue
}
// ServiceUnavailble error is returned when the API server is blocked by storage version updates
if apierrors.IsServiceUnavailable(err) {
klog.Infof("going to retry, unable to create PriorityClass %s: %v", pc.Name, err)
return false, nil
}
return false, err
} else {
// Unable to get the priority class for reasons other than "not found".
klog.Warningf("unable to get PriorityClass %v: %v. Retrying...", pc.Name, err)