Skip to content

Commit

Permalink
fix for etcd-snapshot delete with --etcd-s3 flag (#8110)
Browse files Browse the repository at this point in the history
k3s etcd-snapshot save --etcd-s3 ... is creating a local snapshot and uploading it to s3 while k3s etcd-snapshot delete --etcd-s3 ... was deleting the snapshot only on s3 buckets, this commit change the behavior of delete to do it locally and on s3

Signed-off-by: Ian Cardoso <[email protected]>
(cherry picked from commit e551308)
  • Loading branch information
osodracnai authored and brandond committed Aug 5, 2023
1 parent 2adec13 commit 9fc75e7
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1704,21 +1704,26 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
}
}()

for {
select {
case <-ctx.Done():
logrus.Errorf("Unable to delete snapshot: %v", ctx.Err())
return e.ReconcileSnapshotData(ctx)
case <-time.After(time.Millisecond * 100):
continue
case err, ok := <-e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}):
if err.Err != nil {
logrus.Errorf("Unable to delete snapshot: %v", err.Err)
}
if !ok {
err = func() error {
for {
select {
case <-ctx.Done():
logrus.Errorf("Unable to delete snapshot: %v", ctx.Err())
return e.ReconcileSnapshotData(ctx)
case <-time.After(time.Millisecond * 100):
continue
case err, ok := <-e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}):
if err.Err != nil {
logrus.Errorf("Unable to delete snapshot: %v", err.Err)
}
if !ok {
return e.ReconcileSnapshotData(ctx)
}
}
}
}()
if err != nil {
return err
}
}

Expand Down

0 comments on commit 9fc75e7

Please sign in to comment.