Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7e6778ef
Commit
7e6778ef
authored
May 05, 2021
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unnecessary code
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
49073cd2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
35 deletions
+30
-35
etcd.go
pkg/etcd/etcd.go
+30
-35
No files found.
pkg/etcd/etcd.go
View file @
7e6778ef
...
@@ -979,58 +979,53 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
...
@@ -979,58 +979,53 @@ 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
{
objectsCh
:=
make
(
chan
minio
.
ObjectInfo
)
logrus
.
Info
(
"Removing the given etcd snapshot(s) from S3"
)
objectsCh
:=
make
(
chan
minio
.
ObjectInfo
)
toCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
defer
cancel
()
toCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Second
*
30
)
go
func
(
ctx
context
.
Context
)
{
defer
c
ancel
(
)
defer
c
lose
(
objectsCh
)
go
func
(
ctx
context
.
Context
)
{
for
{
defer
close
(
objectsCh
)
select
{
case
<-
ctx
.
Done
()
:
return
default
:
opts
:=
minio
.
ListObjectsOptions
{
Recursive
:
true
,
}
for
{
for
obj
:=
range
e
.
s3
.
client
.
ListObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
opts
)
{
select
{
if
obj
.
Err
!=
nil
{
case
<-
ctx
.
Done
()
:
logrus
.
Error
(
obj
.
Err
)
return
continue
default
:
}
for
obj
:=
range
e
.
s3
.
client
.
ListObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
minio
.
ListObjectsOptions
{})
{
if
obj
.
Err
!=
nil
{
logrus
.
Error
(
obj
.
Err
)
continue
}
// iterate through the given snapshots and only
// iterate through the given snapshots and only
// 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
{
if
snapshot
==
obj
.
Key
{
logrus
.
Warnf
(
"snapshot: %s - obj.Key: %s
\n
"
,
snapshot
,
obj
.
Key
)
objectsCh
<-
obj
if
snapshot
==
obj
.
Key
{
}
objectsCh
<-
obj
}
}
}
}
}
}
return
}
}
}(
toCtx
)
for
roErr
:=
range
e
.
s3
.
client
.
RemoveObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
objectsCh
,
minio
.
RemoveObjectsOptions
{})
{
logrus
.
Errorf
(
"Error detected during deletion: %v"
,
roErr
)
}
}
}(
toCtx
)
return
e
.
StoreSnapshotData
(
ctx
)
for
roErr
:=
range
e
.
s3
.
client
.
RemoveObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
objectsCh
,
minio
.
RemoveObjectsOptions
{})
{
}
logrus
.
Errorf
(
"Unable to delete snapshot: %v"
,
roErr
)
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment