From 0624d2a51fcbbca8b1af47a56ce88d5f76968ab1 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 21 Nov 2023 20:15:27 +0000 Subject: [PATCH] Don't apply s3 retention if S3 client failed to initialize Signed-off-by: Brad Davidson --- pkg/etcd/snapshot.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/etcd/snapshot.go b/pkg/etcd/snapshot.go index d11a7fb5b0b9..afdca6e2960d 100644 --- a/pkg/etcd/snapshot.go +++ b/pkg/etcd/snapshot.go @@ -368,14 +368,16 @@ func (e *ETCD) Snapshot(ctx context.Context) error { } else { logrus.Infof("S3 upload complete for %s", snapshotName) } + // Attempt to apply retention even if the upload failed; failure may be due to bucket + // being full or some other condition that retention policy would resolve. + if err := e.s3.snapshotRetention(ctx); err != nil { + logrus.Errorf("Failed to apply s3 snapshot retention policy: %v", err) + } } + // sf is either s3 snapshot metadata, or s3 failure record if err := e.addSnapshotData(*sf); err != nil { return errors.Wrap(err, "failed to sync ETCDSnapshotFile") } - if err := e.s3.snapshotRetention(ctx); err != nil { - logrus.Errorf("Failed to apply s3 snapshot retention policy: %v", err) - } - } } @@ -547,6 +549,7 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error { } if e.config.EtcdS3 { if err := e.initS3IfNil(ctx); err != nil { + logrus.Warnf("Unable to initialize S3 client: %v", err) return err } } @@ -739,6 +742,7 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { // Get snapshots from S3 if e.config.EtcdS3 { if err := e.initS3IfNil(ctx); err != nil { + logrus.Warnf("Unable to initialize S3 client: %v", err) return err }