Client ca post start hook now checks if the system namespace already exists

before creating it.

This avoids apiserver crashloops if a webhook rejects namespace
creation when the apiserver is rebooted.
This commit is contained in:
Chao Xu
2018-01-30 14:56:43 -08:00
parent 7fe25af6b1
commit 83d535aa6c
4 changed files with 46 additions and 22 deletions

View File

@@ -74,7 +74,7 @@ func (h ClientCARegistrationHook) PostStartHook(hookContext genericapiserver.Pos
// tryToWriteClientCAs is here for unit testing with a fake client. This is a wait.ConditionFunc so the bool
// indicates if the condition was met. True when its finished, false when it should retry.
func (h ClientCARegistrationHook) tryToWriteClientCAs(client coreclient.CoreInterface) (bool, error) {
if _, err := client.Namespaces().Create(&api.Namespace{ObjectMeta: metav1.ObjectMeta{Name: metav1.NamespaceSystem}}); err != nil && !apierrors.IsAlreadyExists(err) {
if err := createNamespaceIfNeeded(client, metav1.NamespaceSystem); err != nil {
utilruntime.HandleError(err)
return false, nil
}