Revert "UpdateOrCreateToken get secrets err handling optimization"

This commit is contained in:
Lubomir I. Ivanov 2023-01-14 00:11:49 +02:00 committed by GitHub
parent 2ca95b4df9
commit 7938631e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,6 @@ import (
"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
bootstraputil "k8s.io/cluster-bootstrap/token/util"
@ -42,10 +41,7 @@ func UpdateOrCreateTokens(client clientset.Interface, failIfExists bool, tokens
secretName := bootstraputil.BootstrapTokenSecretName(token.Token.ID)
secret, err := client.CoreV1().Secrets(metav1.NamespaceSystem).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil && !apierrors.IsNotFound(err) {
return err
}
if secret != nil && failIfExists {
if secret != nil && err == nil && failIfExists {
return errors.Errorf("a token with id %q already exists", token.Token.ID)
}