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
6c6adcb5
Unverified
Commit
6c6adcb5
authored
Jul 20, 2021
by
Derek Nola
Committed by
GitHub
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to allow prune to correctly cleanup custom named snapshots (#3649) (#3673)
Signed-off-by:
dereknola
<
derek.nola@suse.com
>
parent
12a78da3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
etcd.go
pkg/etcd/etcd.go
+4
-5
s3.go
pkg/etcd/s3.go
+1
-1
No files found.
pkg/etcd/etcd.go
View file @
6c6adcb5
...
...
@@ -41,7 +41,6 @@ import (
)
const
(
snapshotPrefix
=
"etcd-snapshot-"
endpoint
=
"https://127.0.0.1:2379"
testTimeout
=
time
.
Second
*
10
manageTickerTime
=
time
.
Second
*
15
...
...
@@ -854,7 +853,7 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
// check if we need to perform a retention check
if
e
.
config
.
EtcdSnapshotRetention
>=
1
{
if
err
:=
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
snapshotDir
);
err
!=
nil
{
if
err
:=
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
e
.
config
.
EtcdSnapshotName
,
snapshotDir
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to apply snapshot retention"
)
}
}
...
...
@@ -986,7 +985,7 @@ func (e *ETCD) PruneSnapshots(ctx context.Context) error {
return
e
.
s3
.
snapshotRetention
(
ctx
)
}
return
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
snapshotDir
)
return
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
e
.
config
.
EtcdSnapshotName
,
snapshotDir
)
}
// ListSnapshots is an exported wrapper method that wraps an
...
...
@@ -1206,7 +1205,7 @@ func (e *ETCD) Restore(ctx context.Context) error {
// snapshotRetention iterates through the snapshots and removes the oldest
// leaving the desired number of snapshots.
func
snapshotRetention
(
retention
int
,
snapshotDir
string
)
error
{
func
snapshotRetention
(
retention
int
,
snapshot
Prefix
string
,
snapshot
Dir
string
)
error
{
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
var
snapshotFiles
[]
os
.
FileInfo
...
...
@@ -1214,7 +1213,7 @@ func snapshotRetention(retention int, snapshotDir string) error {
if
err
!=
nil
{
return
err
}
if
strings
.
HasPrefix
(
info
.
Name
(),
snapshotPrefix
+
nodeName
)
{
if
strings
.
HasPrefix
(
info
.
Name
(),
snapshotPrefix
+
"-"
+
nodeName
)
{
snapshotFiles
=
append
(
snapshotFiles
,
info
)
}
return
nil
...
...
pkg/etcd/s3.go
View file @
6c6adcb5
...
...
@@ -157,7 +157,7 @@ func (s *s3) download(ctx context.Context) error {
// naming of the snapshots.
func
(
s
*
s3
)
snapshotPrefix
()
string
{
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
fullSnapshotPrefix
:=
s
napshotPrefix
+
nodeName
fullSnapshotPrefix
:=
s
.
config
.
EtcdSnapshotName
+
"-"
+
nodeName
var
prefix
string
if
s
.
config
.
EtcdS3Folder
!=
""
{
prefix
=
filepath
.
Join
(
s
.
config
.
EtcdS3Folder
,
fullSnapshotPrefix
)
...
...
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