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

Don't apply s3 retention if S3 client failed to initialize

parent a92c4a0f
...@@ -368,14 +368,16 @@ func (e *ETCD) Snapshot(ctx context.Context) error { ...@@ -368,14 +368,16 @@ func (e *ETCD) Snapshot(ctx context.Context) error {
} else { } else {
logrus.Infof("S3 upload complete for %s", snapshotName) 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 { if err := e.addSnapshotData(*sf); err != nil {
return errors.Wrap(err, "failed to sync ETCDSnapshotFile") 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 { ...@@ -547,6 +549,7 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
} }
if e.config.EtcdS3 { if e.config.EtcdS3 {
if err := e.initS3IfNil(ctx); err != nil { if err := e.initS3IfNil(ctx); err != nil {
logrus.Warnf("Unable to initialize S3 client: %v", err)
return err return err
} }
} }
...@@ -739,6 +742,7 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { ...@@ -739,6 +742,7 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
// Get snapshots from S3 // Get snapshots from S3
if e.config.EtcdS3 { if e.config.EtcdS3 {
if err := e.initS3IfNil(ctx); err != nil { if err := e.initS3IfNil(ctx); err != nil {
logrus.Warnf("Unable to initialize S3 client: %v", err)
return err return err
} }
......
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