Commit ea2b3142 authored by Brian Downs's avatar Brian Downs

pr remediations

parent 2fff8da5
FROM k3s:issue-3240
COPY . /go/src/github.com/rancher/k3s/
\ No newline at end of file
......@@ -987,47 +987,50 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
}
objectsCh := make(chan minio.ObjectInfo)
defer close(objectsCh)
toCtx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
defer cancel()
go func(ctx context.Context) {
defer close(objectsCh)
opts := minio.ListObjectsOptions{
Recursive: true,
}
for {
select {
case <-ctx.Done():
for obj := range e.s3.client.ListObjects(ctx, e.config.EtcdS3BucketName, opts) {
if obj.Err != nil {
logrus.Error(obj.Err)
return
default:
opts := minio.ListObjectsOptions{
Recursive: true,
}
}
for obj := range e.s3.client.ListObjects(ctx, e.config.EtcdS3BucketName, opts) {
if obj.Err != nil {
logrus.Error(obj.Err)
continue
}
// iterate through the given snapshots and only
// add them to the channel for remove if they're
// actually found from the bucket listing.
for _, snapshot := range snapshots {
if snapshot == obj.Key {
objectsCh <- obj
}
}
// iterate through the given snapshots and only
// add them to the channel for remove if they're
// actually found from the bucket listing.
for _, snapshot := range snapshots {
if snapshot == obj.Key {
objectsCh <- obj
}
return
}
}
}(toCtx)
for roErr := range e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}) {
logrus.Errorf("Unable to delete snapshot: %v", roErr)
}(ctx)
for {
select {
case <-ctx.Done():
logrus.Errorf("Unable to delete snapshot: %v", ctx.Err)
return e.StoreSnapshotData(ctx)
case <-time.After(time.Millisecond * 100):
continue
case err, ok := <-e.s3.client.RemoveObjects(ctx, e.config.EtcdS3BucketName, objectsCh, minio.RemoveObjectsOptions{}):
fmt.Printf("%#v - %#v\n", err, ok)
if err.Err != nil {
logrus.Errorf("Unable to delete snapshot: %v", err.Err)
}
if !ok {
return e.StoreSnapshotData(ctx)
}
}
}
return e.StoreSnapshotData(ctx)
}
logrus.Info("Removing the given locally stored etcd snapshot(s)")
......
......@@ -65,10 +65,10 @@ func newS3(ctx context.Context, config *config.Control) (*s3, error) {
logrus.Infof("Checking if S3 bucket %s exists", config.EtcdS3BucketName)
toCtx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
ctx, cancel := context.WithTimeout(ctx, defaultS3OpTimeout)
defer cancel()
exists, err := c.BucketExists(toCtx, config.EtcdS3BucketName)
exists, err := c.BucketExists(ctx, config.EtcdS3BucketName)
if err != nil {
return nil, 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