mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
kubeadm: don't fail post upgrade in EnsureAdminClusterRoleBindingImpl if the error is crb already exists
This commit is contained in:
parent
3aa8c59fec
commit
ec1516b45d
@ -694,9 +694,8 @@ func EnsureAdminClusterRoleBindingImpl(ctx context.Context, adminClient, superAd
|
||||
); err != nil {
|
||||
lastError = err
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
// This should not happen, as the previous "create" call that uses
|
||||
// the admin.conf should have passed. Return the error.
|
||||
return true, err
|
||||
klog.V(5).Infof("ClusterRoleBinding %s already exists.", kubeadmconstants.ClusterAdminsGroupAndClusterRoleBinding)
|
||||
return true, nil
|
||||
}
|
||||
// Retry on any other type of error.
|
||||
return false, nil
|
||||
|
@ -850,6 +850,12 @@ func TestEnsureAdminClusterRoleBindingImpl(t *testing.T) {
|
||||
schema.GroupResource{}, "name")
|
||||
})
|
||||
},
|
||||
setupSuperAdminClient: func(client *clientsetfake.Clientset) {
|
||||
client.PrependReactor("create", "clusterrolebindings", func(action clientgotesting.Action) (bool, runtime.Object, error) {
|
||||
return true, nil, apierrors.NewAlreadyExists(
|
||||
schema.GroupResource{}, "name")
|
||||
})
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
@ -916,7 +922,7 @@ func TestEnsureAdminClusterRoleBindingImpl(t *testing.T) {
|
||||
schema.GroupResource{}, "name")
|
||||
})
|
||||
},
|
||||
expectedError: true,
|
||||
expectedError: false,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user