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
beb0d839
Commit
beb0d839
authored
May 04, 2021
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reference node name when needed
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
64577a07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
etcd.go
pkg/etcd/etcd.go
+15
-13
No files found.
pkg/etcd/etcd.go
View file @
beb0d839
...
@@ -65,14 +65,13 @@ var (
...
@@ -65,14 +65,13 @@ var (
)
)
type
ETCD
struct
{
type
ETCD
struct
{
client
*
etcd
.
Client
client
*
etcd
.
Client
config
*
config
.
Control
config
*
config
.
Control
name
string
name
string
runtime
*
config
.
ControlRuntime
runtime
*
config
.
ControlRuntime
address
string
address
string
cron
*
cron
.
Cron
cron
*
cron
.
Cron
s3
*
s3
s3
*
s3
nodeName
string
}
}
type
learnerProgress
struct
{
type
learnerProgress
struct
{
...
@@ -92,8 +91,7 @@ type Members struct {
...
@@ -92,8 +91,7 @@ type Members struct {
// ETCD with an initialized cron value.
// ETCD with an initialized cron value.
func
NewETCD
()
*
ETCD
{
func
NewETCD
()
*
ETCD
{
return
&
ETCD
{
return
&
ETCD
{
cron
:
cron
.
New
(),
cron
:
cron
.
New
(),
nodeName
:
os
.
Getenv
(
"NODE_NAME"
),
}
}
}
}
...
@@ -948,11 +946,13 @@ func (e *ETCD) listSnapshots(ctx context.Context, snapshotDir string) ([]snapsho
...
@@ -948,11 +946,13 @@ func (e *ETCD) listSnapshots(ctx context.Context, snapshotDir string) ([]snapsho
return
nil
,
err
return
nil
,
err
}
}
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
for
_
,
f
:=
range
files
{
for
_
,
f
:=
range
files
{
snapshots
=
append
(
snapshots
,
snapshotFile
{
snapshots
=
append
(
snapshots
,
snapshotFile
{
Name
:
f
.
Name
(),
Name
:
f
.
Name
(),
Location
:
"file://"
+
filepath
.
Join
(
snapshotDir
,
f
.
Name
()),
Location
:
"file://"
+
filepath
.
Join
(
snapshotDir
,
f
.
Name
()),
NodeName
:
e
.
nodeName
,
NodeName
:
nodeName
,
CreatedAt
:
&
metav1
.
Time
{
CreatedAt
:
&
metav1
.
Time
{
Time
:
f
.
ModTime
(),
Time
:
f
.
ModTime
(),
},
},
...
@@ -1022,18 +1022,20 @@ func (e *ETCD) StoreSnapshotData(ctx context.Context) error {
...
@@ -1022,18 +1022,20 @@ func (e *ETCD) StoreSnapshotData(ctx context.Context) error {
snapshotConfigMap
.
Data
=
make
(
map
[
string
]
string
,
0
)
snapshotConfigMap
.
Data
=
make
(
map
[
string
]
string
,
0
)
}
}
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
// remove entries for this node only
// remove entries for this node only
for
k
,
v
:=
range
snapshotConfigMap
.
Data
{
for
k
,
v
:=
range
snapshotConfigMap
.
Data
{
var
sf
snapshotFile
var
sf
snapshotFile
if
err
:=
json
.
Unmarshal
([]
byte
(
v
),
&
sf
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
v
),
&
sf
);
err
!=
nil
{
return
err
return
err
}
}
if
sf
.
NodeName
==
e
.
nodeName
||
sf
.
NodeName
==
"s3"
{
if
sf
.
NodeName
==
nodeName
||
sf
.
NodeName
==
"s3"
{
delete
(
snapshotConfigMap
.
Data
,
k
)
delete
(
snapshotConfigMap
.
Data
,
k
)
}
}
}
}
// this node's entries to the ConfigMap
//
save
this node's entries to the ConfigMap
for
k
,
v
:=
range
data
{
for
k
,
v
:=
range
data
{
snapshotConfigMap
.
Data
[
k
]
=
v
snapshotConfigMap
.
Data
[
k
]
=
v
}
}
...
...
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