Commit c62308b7 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Fix issue with snapshot metadata configmap

Omit snapshot list configmap entries for snapshots without extra metadata; reduce log level of warnings about missing s3 metadata files. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit 2088218c) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent ce7b9ed7
...@@ -425,10 +425,18 @@ func (s *S3) listSnapshots(ctx context.Context) (map[string]snapshotFile, error) ...@@ -425,10 +425,18 @@ func (s *S3) listSnapshots(ctx context.Context) (map[string]snapshotFile, error)
if sf, ok := snapshots[sfKey]; ok { if sf, ok := snapshots[sfKey]; ok {
logrus.Debugf("Loading snapshot metadata from s3://%s/%s", s.config.EtcdS3BucketName, metadataKey) 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 { 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 { } else {
if m, err := ioutil.ReadAll(obj); err != nil { 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 { } else {
sf.Metadata = base64.StdEncoding.EncodeToString(m) sf.Metadata = base64.StdEncoding.EncodeToString(m)
snapshots[sfKey] = sf snapshots[sfKey] = sf
......
...@@ -67,7 +67,9 @@ func (e *etcdSnapshotHandler) sync(key string, esf *apisv1.ETCDSnapshotFile) (*a ...@@ -67,7 +67,9 @@ func (e *etcdSnapshotHandler) sync(key string, esf *apisv1.ETCDSnapshotFile) (*a
} }
return nil, err 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 return nil, nil
} }
...@@ -209,11 +211,13 @@ func (e *etcdSnapshotHandler) reconcile() error { ...@@ -209,11 +211,13 @@ func (e *etcdSnapshotHandler) reconcile() error {
snapshots := map[string]*apisv1.ETCDSnapshotFile{} snapshots := map[string]*apisv1.ETCDSnapshotFile{}
for i := range snapshotList.Items { for i := range snapshotList.Items {
esf := &snapshotList.Items[i] esf := &snapshotList.Items[i]
if esf.DeletionTimestamp.IsZero() { // 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) sfKey := generateETCDSnapshotFileConfigMapKey(*esf)
snapshots[sfKey] = esf snapshots[sfKey] = esf
} }
}
// Make a copy of the configmap for change detection // Make a copy of the configmap for change detection
existing := snapshotConfigMap.DeepCopyObject() existing := snapshotConfigMap.DeepCopyObject()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment