Commit 7e6778ef authored by Brian Downs's avatar Brian Downs

remove unnecessary code

parent 49073cd2
...@@ -979,19 +979,16 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error { ...@@ -979,19 +979,16 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
} }
if e.config.EtcdS3 { if e.config.EtcdS3 {
logrus.Info("Removing the given etcd snapshot from S3") logrus.Info("Removing the given etcd snapshot(s) from S3")
logrus.Debugf("Removing the given etcd snapshot from S3: %v", snapshots) logrus.Debugf("Removing the given etcd snapshot from S3: %v", snapshots)
if e.initS3IfNil(ctx); err != nil { if e.initS3IfNil(ctx); err != nil {
return err return err
} }
if len(snapshots) > 1 {
logrus.Info("Removing the given etcd snapshot(s) from S3")
objectsCh := make(chan minio.ObjectInfo) objectsCh := make(chan minio.ObjectInfo)
toCtx, cancel := context.WithTimeout(ctx, time.Second*30) toCtx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
defer cancel() defer cancel()
go func(ctx context.Context) { go func(ctx context.Context) {
...@@ -1002,7 +999,11 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error { ...@@ -1002,7 +999,11 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
case <-ctx.Done(): case <-ctx.Done():
return return
default: default:
for obj := range e.s3.client.ListObjects(ctx, e.config.EtcdS3BucketName, minio.ListObjectsOptions{}) { opts := minio.ListObjectsOptions{
Recursive: true,
}
for obj := range e.s3.client.ListObjects(ctx, e.config.EtcdS3BucketName, opts) {
if obj.Err != nil { if obj.Err != nil {
logrus.Error(obj.Err) logrus.Error(obj.Err)
continue continue
...@@ -1012,25 +1013,19 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error { ...@@ -1012,25 +1013,19 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
// add them to the channel for remove if they're // add them to the channel for remove if they're
// actually found from the bucket listing. // actually found from the bucket listing.
for _, snapshot := range snapshots { for _, snapshot := range snapshots {
logrus.Warnf("snapshot: %s - obj.Key: %s\n", snapshot, obj.Key)
if snapshot == obj.Key { if snapshot == obj.Key {
objectsCh <- obj objectsCh <- obj
} }
} }
} }
return
} }
} }
}(toCtx) }(toCtx)
for roErr := range e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}) { for roErr := range e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}) {
logrus.Errorf("Error detected during deletion: %v", roErr) logrus.Errorf("Unable to delete snapshot: %v", roErr)
}
return e.StoreSnapshotData(ctx)
}
if err = e.s3.client.RemoveObject(ctx, e.config.EtcdS3BucketName, snapshots[0], minio.RemoveObjectOptions{}); err != nil {
return errors.Wrap(err, "error detected during deletion")
} }
return e.StoreSnapshotData(ctx) return e.StoreSnapshotData(ctx)
......
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