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
e8cd28ae
Commit
e8cd28ae
authored
Jul 17, 2018
by
Shimin Guo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a panic due to assignment to nil map
parent
da1bb028
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+3
-0
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+27
-0
No files found.
pkg/kubelet/kubelet_node_status.go
View file @
e8cd28ae
...
...
@@ -162,6 +162,9 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
}
var
needsUpdate
bool
=
false
if
existingNode
.
Labels
==
nil
{
existingNode
.
Labels
=
make
(
map
[
string
]
string
)
}
//Set default labels but make sure to not set labels with empty values
for
_
,
label
:=
range
defaultLabels
{
if
_
,
hasInitialValue
:=
initialNode
.
Labels
[
label
];
!
hasInitialValue
{
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
e8cd28ae
...
...
@@ -1414,6 +1414,33 @@ func TestUpdateDefaultLabels(t *testing.T) {
kubeletapis
.
LabelArch
:
"new-arch"
,
},
},
{
name
:
"not panic when existing node has nil labels"
,
initialNode
:
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
kubeletapis
.
LabelHostname
:
"new-hostname"
,
kubeletapis
.
LabelZoneFailureDomain
:
"new-zone-failure-domain"
,
kubeletapis
.
LabelZoneRegion
:
"new-zone-region"
,
kubeletapis
.
LabelInstanceType
:
"new-instance-type"
,
kubeletapis
.
LabelOS
:
"new-os"
,
kubeletapis
.
LabelArch
:
"new-arch"
,
},
},
},
existingNode
:
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{},
},
needsUpdate
:
true
,
finalLabels
:
map
[
string
]
string
{
kubeletapis
.
LabelHostname
:
"new-hostname"
,
kubeletapis
.
LabelZoneFailureDomain
:
"new-zone-failure-domain"
,
kubeletapis
.
LabelZoneRegion
:
"new-zone-region"
,
kubeletapis
.
LabelInstanceType
:
"new-instance-type"
,
kubeletapis
.
LabelOS
:
"new-os"
,
kubeletapis
.
LabelArch
:
"new-arch"
,
},
},
}
for
_
,
tc
:=
range
cases
{
...
...
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