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
ca7aeed0
Unverified
Commit
ca7aeed0
authored
Aug 03, 2023
by
Vitor Savian
Committed by
GitHub
Aug 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Etcd snapshots retention when node name changes (#8099)
Fixed the etcd retention to delete orphaned snapshots Signed-off-by:
Vitor
<
vitor.savian@suse.com
>
parent
23d6842f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
6 deletions
+3
-6
etcd.go
pkg/etcd/etcd.go
+2
-4
s3.go
pkg/etcd/s3.go
+1
-2
No files found.
pkg/etcd/etcd.go
View file @
ca7aeed0
...
@@ -1425,7 +1425,6 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
...
@@ -1425,7 +1425,6 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
if
err
:=
e
.
addSnapshotData
(
*
sf
);
err
!=
nil
{
if
err
:=
e
.
addSnapshotData
(
*
sf
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to save local snapshot data to configmap"
)
return
errors
.
Wrap
(
err
,
"failed to save local snapshot data to configmap"
)
}
}
if
err
:=
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
e
.
config
.
EtcdSnapshotName
,
snapshotDir
);
err
!=
nil
{
if
err
:=
snapshotRetention
(
e
.
config
.
EtcdSnapshotRetention
,
e
.
config
.
EtcdSnapshotName
,
snapshotDir
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to apply local snapshot retention policy"
)
return
errors
.
Wrap
(
err
,
"failed to apply local snapshot retention policy"
)
}
}
...
@@ -2025,15 +2024,14 @@ func snapshotRetention(retention int, snapshotPrefix string, snapshotDir string)
...
@@ -2025,15 +2024,14 @@ func snapshotRetention(retention int, snapshotPrefix string, snapshotDir string)
return
nil
return
nil
}
}
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
logrus
.
Infof
(
"Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s"
,
retention
,
snapshotPrefix
,
snapshotDir
)
logrus
.
Infof
(
"Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s"
,
retention
,
snapshotPrefix
+
"-"
+
nodeName
,
snapshotDir
)
var
snapshotFiles
[]
os
.
FileInfo
var
snapshotFiles
[]
os
.
FileInfo
if
err
:=
filepath
.
Walk
(
snapshotDir
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
:=
filepath
.
Walk
(
snapshotDir
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
strings
.
HasPrefix
(
info
.
Name
(),
snapshotPrefix
+
"-"
+
nodeName
)
{
if
strings
.
HasPrefix
(
info
.
Name
(),
snapshotPrefix
)
{
snapshotFiles
=
append
(
snapshotFiles
,
info
)
snapshotFiles
=
append
(
snapshotFiles
,
info
)
}
}
return
nil
return
nil
...
...
pkg/etcd/s3.go
View file @
ca7aeed0
...
@@ -212,8 +212,7 @@ func (s *S3) Download(ctx context.Context) error {
...
@@ -212,8 +212,7 @@ func (s *S3) Download(ctx context.Context) error {
// snapshotPrefix returns the prefix used in the
// snapshotPrefix returns the prefix used in the
// naming of the snapshots.
// naming of the snapshots.
func
(
s
*
S3
)
snapshotPrefix
()
string
{
func
(
s
*
S3
)
snapshotPrefix
()
string
{
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
fullSnapshotPrefix
:=
s
.
config
.
EtcdSnapshotName
fullSnapshotPrefix
:=
s
.
config
.
EtcdSnapshotName
+
"-"
+
nodeName
var
prefix
string
var
prefix
string
if
s
.
config
.
EtcdS3Folder
!=
""
{
if
s
.
config
.
EtcdS3Folder
!=
""
{
prefix
=
filepath
.
Join
(
s
.
config
.
EtcdS3Folder
,
fullSnapshotPrefix
)
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