diff --git a/pkg/etcd/s3.go b/pkg/etcd/s3.go index abdbf8f86d1c..1e96ebabb110 100644 --- a/pkg/etcd/s3.go +++ b/pkg/etcd/s3.go @@ -425,10 +425,18 @@ func (s *S3) listSnapshots(ctx context.Context) (map[string]snapshotFile, error) if sf, ok := snapshots[sfKey]; ok { logrus.Debugf("Loading snapshot metadata from s3://%s/%s", s.config.EtcdS3BucketName, metadataKey) if obj, err := s.client.GetObject(ctx, s.config.EtcdS3BucketName, metadataKey, minio.GetObjectOptions{}); err != nil { - logrus.Warnf("Failed to get snapshot metadata: %v", err) + if isNotExist(err) { + logrus.Debugf("Failed to get snapshot metadata: %v", err) + } else { + logrus.Warnf("Failed to get snapshot metadata for %s: %v", filename, err) + } } else { if m, err := ioutil.ReadAll(obj); err != nil { - logrus.Warnf("Failed to read snapshot metadata: %v", err) + if isNotExist(err) { + logrus.Debugf("Failed to read snapshot metadata: %v", err) + } else { + logrus.Warnf("Failed to read snapshot metadata for %s: %v", filename, err) + } } else { sf.Metadata = base64.StdEncoding.EncodeToString(m) snapshots[sfKey] = sf diff --git a/pkg/etcd/snapshot_controller.go b/pkg/etcd/snapshot_controller.go index 6c04d3569b2c..a21da8481719 100644 --- a/pkg/etcd/snapshot_controller.go +++ b/pkg/etcd/snapshot_controller.go @@ -67,7 +67,9 @@ func (e *etcdSnapshotHandler) sync(key string, esf *apisv1.ETCDSnapshotFile) (*a } return nil, err } - if esf == nil || !esf.DeletionTimestamp.IsZero() { + + // Do not create entries for snapshots that have been deleted or do not have extra metadata + if esf == nil || !esf.DeletionTimestamp.IsZero() || len(esf.Spec.Metadata) == 0 { return nil, nil } @@ -209,10 +211,12 @@ func (e *etcdSnapshotHandler) reconcile() error { snapshots := map[string]*apisv1.ETCDSnapshotFile{} for i := range snapshotList.Items { esf := &snapshotList.Items[i] - if esf.DeletionTimestamp.IsZero() { - sfKey := generateETCDSnapshotFileConfigMapKey(*esf) - snapshots[sfKey] = esf + // Do not create entries for snapshots that have been deleted or do not have extra metadata + if !esf.DeletionTimestamp.IsZero() || len(esf.Spec.Metadata) == 0 { + continue } + sfKey := generateETCDSnapshotFileConfigMapKey(*esf) + snapshots[sfKey] = esf } // Make a copy of the configmap for change detection