Skip to content

Commit

Permalink
Merge pull request #54074 from liggitt/automated-cherry-pick-of-#5407…
Browse files Browse the repository at this point in the history
…3-upstream-release-1.8

Automatic merge from submit-queue.

Automated cherry pick of #54073

Cherry pick of #54073 on release-1.8.

#54073: Do not remove kubelet labels during startup
  • Loading branch information
Kubernetes Submit Queue authored Oct 21, 2017
2 parents a20b848 + a68bcf5 commit 4f5f672
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kubelet/kubelet_node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
var needsUpdate bool = false
//Set default labels but make sure to not set labels with empty values
for _, label := range defaultLabels {
if _, hasInitialValue := initialNode.Labels[label]; !hasInitialValue {
continue
}

if existingNode.Labels[label] != initialNode.Labels[label] {
existingNode.Labels[label] = initialNode.Labels[label]
needsUpdate = true
Expand Down
31 changes: 31 additions & 0 deletions pkg/kubelet/kubelet_node_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,37 @@ func TestUpdateDefaultLabels(t *testing.T) {
"please-persist": "foo",
},
},
{
name: "make sure existing labels do not get deleted when initial node has no opinion",
initialNode: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{},
},
},
existingNode: &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",
"please-persist": "foo",
},
},
},
needsUpdate: false,
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",
"please-persist": "foo",
},
},
{
name: "no update needed",
initialNode: &v1.Node{
Expand Down

0 comments on commit 4f5f672

Please sign in to comment.