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
a1220f7f
Commit
a1220f7f
authored
Apr 30, 2021
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability for node to save etcd snapshot state at start.
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
a74fb990
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
cluster.go
pkg/cluster/cluster.go
+6
-0
drivers.go
pkg/cluster/managed/drivers.go
+2
-1
etcd.go
pkg/etcd/etcd.go
+16
-3
No files found.
pkg/cluster/cluster.go
View file @
a1220f7f
...
@@ -110,6 +110,12 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
...
@@ -110,6 +110,12 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
}()
}()
}
}
go
func
()
{
if
err
:=
c
.
managedDB
.
StoreSnapshotData
(
ctx
);
err
!=
nil
{
logrus
.
Error
(
err
)
}
}()
return
ready
,
nil
return
ready
,
nil
}
}
...
...
pkg/cluster/managed/drivers.go
View file @
a1220f7f
...
@@ -21,9 +21,10 @@ type Driver interface {
...
@@ -21,9 +21,10 @@ type Driver interface {
Test
(
ctx
context
.
Context
)
error
Test
(
ctx
context
.
Context
)
error
Restore
(
ctx
context
.
Context
)
error
Restore
(
ctx
context
.
Context
)
error
EndpointName
()
string
EndpointName
()
string
Snapshot
(
ctx
context
.
Context
,
config
*
config
.
Control
)
error
StoreSnapshotData
(
ctx
context
.
Context
)
error
GetMembersClientURLs
(
ctx
context
.
Context
)
([]
string
,
error
)
GetMembersClientURLs
(
ctx
context
.
Context
)
([]
string
,
error
)
RemoveSelf
(
ctx
context
.
Context
)
error
RemoveSelf
(
ctx
context
.
Context
)
error
Snapshot
(
ctx
context
.
Context
,
config
*
config
.
Control
)
error
}
}
func
RegisterDriver
(
d
Driver
)
{
func
RegisterDriver
(
d
Driver
)
{
...
...
pkg/etcd/etcd.go
View file @
a1220f7f
...
@@ -862,7 +862,7 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
...
@@ -862,7 +862,7 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
}
}
}
}
return
e
.
StoreSnapshotData
(
ctx
,
snapshotDir
)
return
e
.
StoreSnapshotData
(
ctx
)
}
}
type
s3Config
struct
{
type
s3Config
struct
{
...
@@ -899,8 +899,16 @@ func (e *ETCD) listSnapshots(ctx context.Context, snapshotDir string) ([]snapsho
...
@@ -899,8 +899,16 @@ func (e *ETCD) listSnapshots(ctx context.Context, snapshotDir string) ([]snapsho
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
defer
cancel
()
if
e
.
s3
==
nil
{
s3
,
err
:=
newS3
(
ctx
,
e
.
config
)
if
err
!=
nil
{
return
nil
,
err
}
e
.
s3
=
s3
}
objects
:=
e
.
s3
.
client
.
ListObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
minio
.
ListObjectsOptions
{})
objects
:=
e
.
s3
.
client
.
ListObjects
(
ctx
,
e
.
config
.
EtcdS3BucketName
,
minio
.
ListObjectsOptions
{})
logrus
.
Warn
(
"XXX - after s3 call
\n
"
)
for
obj
:=
range
objects
{
for
obj
:=
range
objects
{
if
obj
.
Err
!=
nil
{
if
obj
.
Err
!=
nil
{
return
nil
,
obj
.
Err
return
nil
,
obj
.
Err
...
@@ -969,11 +977,16 @@ func updateSnapshotData(data map[string]string, snapshotFiles []snapshotFile) er
...
@@ -969,11 +977,16 @@ func updateSnapshotData(data map[string]string, snapshotFiles []snapshotFile) er
}
}
// StoreSnapshotData stores the given snapshot data in the "snapshots" ConfigMap.
// StoreSnapshotData stores the given snapshot data in the "snapshots" ConfigMap.
func
(
e
*
ETCD
)
StoreSnapshotData
(
ctx
context
.
Context
,
snapshotDir
string
)
error
{
func
(
e
*
ETCD
)
StoreSnapshotData
(
ctx
context
.
Context
)
error
{
logrus
.
Infof
(
"Saving current etcd snapshot set to %s ConfigMap"
,
snapshotConfigMapName
)
logrus
.
Infof
(
"Saving current etcd snapshot set to %s ConfigMap"
,
snapshotConfigMapName
)
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
snapshotDir
,
err
:=
snapshotDir
(
e
.
config
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to get the snapshot dir"
)
}
return
retry
.
OnError
(
retry
.
DefaultBackoff
,
func
(
err
error
)
bool
{
return
retry
.
OnError
(
retry
.
DefaultBackoff
,
func
(
err
error
)
bool
{
return
apierrors
.
IsConflict
(
err
)
||
apierrors
.
IsAlreadyExists
(
err
)
return
apierrors
.
IsConflict
(
err
)
||
apierrors
.
IsAlreadyExists
(
err
)
},
func
()
error
{
},
func
()
error
{
...
...
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