Fix multiple bootstrap keys found

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
pull/3688/head
galal-hussein 2021-07-21 02:50:36 +02:00
parent 37fcb61f5e
commit a65e5b6466
1 changed files with 13 additions and 12 deletions

View File

@ -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")