From a65e5b6466cbbf2643cde059ef5d6142d73adfdc Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Wed, 21 Jul 2021 02:50:36 +0200 Subject: [PATCH] Fix multiple bootstrap keys found Signed-off-by: galal-hussein --- pkg/cluster/storage.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/cluster/storage.go b/pkg/cluster/storage.go index e16bf6a8b5..ca31ae9464 100644 --- a/pkg/cluster/storage.go +++ b/pkg/cluster/storage.go @@ -132,20 +132,21 @@ func (c *Cluster) getBootstrapKeyFromStorage(ctx context.Context, storageClient return nil, false, nil } if len(bootstrapList) > 1 { - return nil, false, errors.New("found multiple bootstrap keys in storage") + logrus.Warn("found multiple bootstrap keys in storage") } - bootstrapKV := bootstrapList[0] - // checking for empty string bootstrap key - switch string(bootstrapKV.Key) { - case emptyStringKey: - logrus.Warn("bootstrap data encrypted with empty string, deleting and resaving with token") - c.saveBootstrap = true - if err := storageClient.Delete(ctx, emptyStringKey, bootstrapKV.Modified); err != nil { - return nil, false, err + for _, bootstrapKV := range bootstrapList { + // checking for empty string bootstrap key + switch string(bootstrapKV.Key) { + case emptyStringKey: + logrus.Warn("bootstrap data encrypted with empty string, deleting and resaving with token") + c.saveBootstrap = true + if err := storageClient.Delete(ctx, emptyStringKey, bootstrapKV.Modified); err != nil { + return nil, false, err + } + return &bootstrapKV, true, nil + case tokenKey: + return &bootstrapKV, false, nil } - return &bootstrapKV, true, nil - case tokenKey: - return &bootstrapKV, false, nil } return nil, false, errors.New("bootstrap data already found and encrypted with different token")