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
d71b3358
Unverified
Commit
d71b3358
authored
Dec 14, 2021
by
Hussein Galal
Committed by
GitHub
Dec 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix snapshot restoration on fresh nodes (#4737)
Signed-off-by:
galal-hussein
<
hussein.galal.ahmed.11@gmail.com
>
parent
bf4e037f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
server.go
pkg/cli/server/server.go
+1
-0
bootstrap.go
pkg/cluster/bootstrap.go
+4
-5
etcd.go
pkg/etcd/etcd.go
+5
-0
No files found.
pkg/cli/server/server.go
View file @
d71b3358
...
@@ -174,6 +174,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -174,6 +174,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
serverConfig
.
ControlConfig
.
DisableScheduler
=
true
serverConfig
.
ControlConfig
.
DisableScheduler
=
true
serverConfig
.
ControlConfig
.
DisableCCM
=
true
serverConfig
.
ControlConfig
.
DisableCCM
=
true
close
(
agentReady
)
dataDir
,
err
:=
datadir
.
LocalHome
(
cfg
.
DataDir
,
false
)
dataDir
,
err
:=
datadir
.
LocalHome
(
cfg
.
DataDir
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/cluster/bootstrap.go
View file @
d71b3358
...
@@ -311,12 +311,11 @@ const systemTimeSkew = int64(3)
...
@@ -311,12 +311,11 @@ const systemTimeSkew = int64(3)
// isMigrated checks to see if the given bootstrap data
// isMigrated checks to see if the given bootstrap data
// is in the latest format.
// is in the latest format.
func
isMigrated
(
buf
io
.
ReadSeeker
)
bool
{
func
isMigrated
(
buf
io
.
ReadSeeker
,
files
*
bootstrap
.
PathsDataformat
)
bool
{
buf
.
Seek
(
0
,
0
)
buf
.
Seek
(
0
,
0
)
defer
buf
.
Seek
(
0
,
0
)
defer
buf
.
Seek
(
0
,
0
)
files
:=
make
(
bootstrap
.
PathsDataformat
)
if
err
:=
json
.
NewDecoder
(
buf
)
.
Decode
(
files
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
buf
)
.
Decode
(
&
files
);
err
!=
nil
{
// This will fail if data is being pulled from old an cluster since
// This will fail if data is being pulled from old an cluster since
// older clusters used a map[string][]byte for the data structure.
// older clusters used a map[string][]byte for the data structure.
// Therefore, we need to perform a migration to the newer bootstrap
// Therefore, we need to perform a migration to the newer bootstrap
...
@@ -342,7 +341,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
...
@@ -342,7 +341,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
// from an older version of k3s. That version might not have the new data format
// from an older version of k3s. That version might not have the new data format
// and we should write the correct format.
// and we should write the correct format.
files
:=
make
(
bootstrap
.
PathsDataformat
)
files
:=
make
(
bootstrap
.
PathsDataformat
)
if
!
isMigrated
(
buf
)
{
if
!
isMigrated
(
buf
,
&
files
)
{
if
err
:=
migrateBootstrapData
(
ctx
,
buf
,
files
);
err
!=
nil
{
if
err
:=
migrateBootstrapData
(
ctx
,
buf
,
files
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -423,7 +422,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
...
@@ -423,7 +422,7 @@ func (c *Cluster) ReconcileBootstrapData(ctx context.Context, buf io.ReadSeeker,
}
}
files
:=
make
(
bootstrap
.
PathsDataformat
)
files
:=
make
(
bootstrap
.
PathsDataformat
)
if
!
isMigrated
(
buf
)
{
if
!
isMigrated
(
buf
,
&
files
)
{
if
err
:=
migrateBootstrapData
(
ctx
,
buf
,
files
);
err
!=
nil
{
if
err
:=
migrateBootstrapData
(
ctx
,
buf
,
files
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/etcd/etcd.go
View file @
d71b3358
...
@@ -198,6 +198,11 @@ func (e *ETCD) Reset(ctx context.Context, rebootstrap func() error) error {
...
@@ -198,6 +198,11 @@ func (e *ETCD) Reset(ctx context.Context, rebootstrap func() error) error {
t
:=
time
.
NewTicker
(
5
*
time
.
Second
)
t
:=
time
.
NewTicker
(
5
*
time
.
Second
)
defer
t
.
Stop
()
defer
t
.
Stop
()
for
range
t
.
C
{
for
range
t
.
C
{
// resetting the apiaddresses to nil since we are doing a restoration
if
_
,
err
:=
e
.
client
.
Put
(
ctx
,
AddressKey
,
""
);
err
!=
nil
{
logrus
.
Warnf
(
"failed to reset api addresses key in etcd: %v"
,
err
)
continue
}
if
err
:=
e
.
Test
(
ctx
);
err
==
nil
{
if
err
:=
e
.
Test
(
ctx
);
err
==
nil
{
members
,
err
:=
e
.
client
.
MemberList
(
ctx
)
members
,
err
:=
e
.
client
.
MemberList
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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