diff --git a/pkg/kubelet/config/config.go b/pkg/kubelet/config/config.go index 6263e0e2ede..99a08b69d3c 100644 --- a/pkg/kubelet/config/config.go +++ b/pkg/kubelet/config/config.go @@ -400,6 +400,7 @@ func updateAnnotations(existing, ref *api.Pod) { func podsDifferSemantically(existing, ref *api.Pod) bool { if reflect.DeepEqual(existing.Spec, ref.Spec) && + reflect.DeepEqual(existing.Labels, ref.Labels) && reflect.DeepEqual(existing.DeletionTimestamp, ref.DeletionTimestamp) && reflect.DeepEqual(existing.DeletionGracePeriodSeconds, ref.DeletionGracePeriodSeconds) && isAnnotationMapEqual(existing.Annotations, ref.Annotations) { @@ -423,6 +424,7 @@ func checkAndUpdatePod(existing, ref *api.Pod) bool { ref.Annotations[kubelet.ConfigFirstSeenAnnotationKey] = existing.Annotations[kubelet.ConfigFirstSeenAnnotationKey] existing.Spec = ref.Spec + existing.Labels = ref.Labels existing.DeletionTimestamp = ref.DeletionTimestamp existing.DeletionGracePeriodSeconds = ref.DeletionGracePeriodSeconds updateAnnotations(existing, ref) diff --git a/pkg/kubelet/config/config_test.go b/pkg/kubelet/config/config_test.go index 2fdcccec6a3..b2db9114d78 100644 --- a/pkg/kubelet/config/config_test.go +++ b/pkg/kubelet/config/config_test.go @@ -298,3 +298,26 @@ func TestPodUpdateAnnotations(t *testing.T) { channel <- podUpdate expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, TestSource, pod)) } + +func TestPodUpdateLables(t *testing.T) { + channel, ch, _ := createPodConfigTester(PodConfigNotificationIncremental) + + pod := CreateValidPod("foo2", "new") + pod.Labels = make(map[string]string, 0) + pod.Labels["key"] = "value" + + clone, err := conversion.NewCloner().DeepCopy(pod) + if err != nil { + t.Fatalf("%v", err) + } + + podUpdate := CreatePodUpdate(kubelet.SET, TestSource, clone.(*api.Pod)) + channel <- podUpdate + expectPodUpdate(t, ch, CreatePodUpdate(kubelet.ADD, TestSource, pod)) + + pod.Labels["key"] = "newValue" + podUpdate = CreatePodUpdate(kubelet.SET, TestSource, pod) + channel <- podUpdate + expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, TestSource, pod)) + +}