mirror of https://github.com/k3s-io/k3s
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: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 2088218c5f
)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/8889/head
parent
ce7b9ed708
commit
c62308b764
|
@ -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
|
||||||
}
|
}
|
||||||
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,10 +211,12 @@ 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
|
||||||
sfKey := generateETCDSnapshotFileConfigMapKey(*esf)
|
if !esf.DeletionTimestamp.IsZero() || len(esf.Spec.Metadata) == 0 {
|
||||||
snapshots[sfKey] = esf
|
continue
|
||||||
}
|
}
|
||||||
|
sfKey := generateETCDSnapshotFileConfigMapKey(*esf)
|
||||||
|
snapshots[sfKey] = esf
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a copy of the configmap for change detection
|
// Make a copy of the configmap for change detection
|
||||||
|
|
Loading…
Reference in New Issue