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
34080b23
Unverified
Commit
34080b23
authored
Oct 15, 2021
by
Brian Downs
Committed by
GitHub
Oct 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy old bootstrap buffer data for use during migration (#4215)
parent
0a91dbb3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
bootstrap.go
pkg/cluster/bootstrap.go
+5
-3
storage.go
pkg/cluster/storage.go
+1
-2
No files found.
pkg/cluster/bootstrap.go
View file @
34080b23
...
...
@@ -154,7 +154,7 @@ func (c *Cluster) certDirsExist() error {
}
// migrateBootstrapData migrates bootstrap data from the old format to the new format.
func
migrateBootstrapData
(
ctx
context
.
Context
,
data
*
bytes
.
Buff
er
,
files
bootstrap
.
PathsDataformat
)
error
{
func
migrateBootstrapData
(
ctx
context
.
Context
,
data
io
.
Read
er
,
files
bootstrap
.
PathsDataformat
)
error
{
logrus
.
Info
(
"Migrating bootstrap data to new format"
)
var
oldBootstrapData
map
[
string
][]
byte
...
...
@@ -182,7 +182,7 @@ const systemTimeSkew = int64(3)
// bootstrap data in the datastore is newer than on disk or different
// and dependingon where the difference is, the newer data is written
// to the older.
func
(
c
*
Cluster
)
ReconcileBootstrapData
(
ctx
context
.
Context
,
buf
*
bytes
.
Buff
er
,
crb
*
config
.
ControlRuntimeBootstrap
)
error
{
func
(
c
*
Cluster
)
ReconcileBootstrapData
(
ctx
context
.
Context
,
buf
io
.
ReadSeek
er
,
crb
*
config
.
ControlRuntimeBootstrap
)
error
{
logrus
.
Info
(
"Reconciling bootstrap data between datastore and disk"
)
if
err
:=
c
.
certDirsExist
();
err
!=
nil
{
...
...
@@ -243,11 +243,13 @@ RETRY:
}
files
:=
make
(
bootstrap
.
PathsDataformat
)
if
err
:=
json
.
NewDecoder
(
buf
)
.
Decode
(
&
files
);
err
!=
nil
{
// This will fail if data is being pulled from old an cluster since
// older clusters used a map[string][]byte for the data structure.
// Therefore, we need to perform a migration to the newer bootstrap
// format; bootstrap.BootstrapFile.
buf
.
Seek
(
0
,
0
)
if
err
:=
migrateBootstrapData
(
ctx
,
buf
,
files
);
err
!=
nil
{
return
err
}
...
...
@@ -395,7 +397,7 @@ func (c *Cluster) httpBootstrap(ctx context.Context) error {
return
err
}
return
c
.
ReconcileBootstrapData
(
ctx
,
bytes
.
New
Buff
er
(
content
),
&
c
.
config
.
Runtime
.
ControlRuntimeBootstrap
)
return
c
.
ReconcileBootstrapData
(
ctx
,
bytes
.
New
Read
er
(
content
),
&
c
.
config
.
Runtime
.
ControlRuntimeBootstrap
)
}
// bootstrap performs cluster bootstrapping, either via HTTP (for managed databases) or direct load from datastore.
...
...
pkg/cluster/storage.go
View file @
34080b23
...
...
@@ -132,8 +132,7 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error {
return
err
}
return
c
.
ReconcileBootstrapData
(
ctx
,
bytes
.
NewBuffer
(
data
),
&
c
.
config
.
Runtime
.
ControlRuntimeBootstrap
)
//return bootstrap.WriteToDiskFromStorage(bytes.NewBuffer(data), &c.runtime.ControlRuntimeBootstrap)
return
c
.
ReconcileBootstrapData
(
ctx
,
bytes
.
NewReader
(
data
),
&
c
.
config
.
Runtime
.
ControlRuntimeBootstrap
)
}
// getBootstrapKeyFromStorage will list all keys that has prefix /bootstrap and will check for key that is
...
...
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