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
ea2b3142
Commit
ea2b3142
authored
May 05, 2021
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pr remediations
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
2fff8da5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
32 deletions
+38
-32
Dockerfile.dapper952916749
Dockerfile.dapper952916749
+3
-0
etcd.go
pkg/etcd/etcd.go
+33
-30
s3.go
pkg/etcd/s3.go
+2
-2
No files found.
Dockerfile.dapper952916749
0 → 100644
View file @
ea2b3142
FROM k3s:issue-3240
COPY . /go/src/github.com/rancher/k3s/
\ No newline at end of file
pkg/etcd/etcd.go
View file @
ea2b3142
...
...
@@ -987,47 +987,50 @@ func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error {
}
objectsCh
:=
make
(
chan
minio
.
ObjectInfo
)
defer
close
(
objectsCh
)
toC
tx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
c
tx
,
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)"
)
...
...
pkg/etcd/s3.go
View file @
ea2b3142
...
...
@@ -65,10 +65,10 @@ func newS3(ctx context.Context, config *config.Control) (*s3, error) {
logrus
.
Infof
(
"Checking if S3 bucket %s exists"
,
config
.
EtcdS3BucketName
)
toC
tx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
c
tx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultS3OpTimeout
)
defer
cancel
()
exists
,
err
:=
c
.
BucketExists
(
toC
tx
,
config
.
EtcdS3BucketName
)
exists
,
err
:=
c
.
BucketExists
(
c
tx
,
config
.
EtcdS3BucketName
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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