Skip to content

Commit ea426f7

Browse files
authored
Merge pull request #7717 from bdehri/rotate-bootstrap-token-if-missing
🐛 Fix to enable bootstrap secret rotation if the secret itself missing
2 parents a95b91c + ad5b522 commit ea426f7

File tree

1 file changed

+7
-0
lines changed
  • bootstrap/kubeadm/internal/controllers

1 file changed

+7
-0
lines changed

bootstrap/kubeadm/internal/controllers/token.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/pkg/errors"
2424
corev1 "k8s.io/api/core/v1"
25+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
2728
bootstraputil "k8s.io/cluster-bootstrap/token/util"
@@ -101,6 +102,12 @@ func refreshToken(ctx context.Context, c client.Client, token string, ttl time.D
101102
func shouldRotate(ctx context.Context, c client.Client, token string, ttl time.Duration) (bool, error) {
102103
secret, err := getToken(ctx, c, token)
103104
if err != nil {
105+
// If the secret is deleted before due to unknown reasons, machine pools cannot be scaled up.
106+
// Since that, secret should be rotated if missing.
107+
// Normally, it is not expected to reach this line.
108+
if apierrors.IsNotFound(err) {
109+
return true, nil
110+
}
104111
return false, err
105112
}
106113

0 commit comments

Comments
 (0)