From 30b3fc455bd1a03ed92ce66c2545b1ca89f39f35 Mon Sep 17 00:00:00 2001 From: Ishan Khare Date: Mon, 9 Oct 2023 15:35:12 +0530 Subject: [PATCH] Revert "fix node labels syncing" --- .../resources/nodes/fake_syncer.go | 2 +- .../resources/nodes/fake_syncer_test.go | 2 +- .../resources/nodes/syncer_test.go | 27 +++++-------------- pkg/controllers/resources/nodes/translate.go | 4 --- test/e2e_node/node.go | 4 --- 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/pkg/controllers/resources/nodes/fake_syncer.go b/pkg/controllers/resources/nodes/fake_syncer.go index 71dfe93e8..9adba0557 100644 --- a/pkg/controllers/resources/nodes/fake_syncer.go +++ b/pkg/controllers/resources/nodes/fake_syncer.go @@ -159,7 +159,7 @@ func CreateFakeNode(ctx context.Context, "beta.kubernetes.io/arch": "amd64", "beta.kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64", - "kubernetes.io/hostname": GetNodeHost(name), + "kubernetes.io/hostname": translate.SafeConcatName("fake", name), "kubernetes.io/os": "linux", }, Annotations: map[string]string{ diff --git a/pkg/controllers/resources/nodes/fake_syncer_test.go b/pkg/controllers/resources/nodes/fake_syncer_test.go index 84169be3e..4b91449a4 100644 --- a/pkg/controllers/resources/nodes/fake_syncer_test.go +++ b/pkg/controllers/resources/nodes/fake_syncer_test.go @@ -66,7 +66,7 @@ func TestFakeSync(t *testing.T) { "beta.kubernetes.io/arch": "amd64", "beta.kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64", - "kubernetes.io/hostname": GetNodeHost(baseName.Name), + "kubernetes.io/hostname": "fake-" + baseName.Name, "kubernetes.io/os": "linux", }, Annotations: map[string]string{ diff --git a/pkg/controllers/resources/nodes/syncer_test.go b/pkg/controllers/resources/nodes/syncer_test.go index 9ee7710f1..61aad3e04 100644 --- a/pkg/controllers/resources/nodes/syncer_test.go +++ b/pkg/controllers/resources/nodes/syncer_test.go @@ -81,14 +81,12 @@ func TestSync(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: baseName.Name, Labels: map[string]string{ - "test": "true", - "kubernetes.io/hostname": GetNodeHost(baseName.Name), + "test": "true", }, Annotations: map[string]string{ "test": "true", translate.ManagedAnnotationsAnnotation: "test", - translate.ManagedLabelsAnnotation: "kubernetes.io/hostname\ntest", - "vcluster.loft.sh/managed-annotations": "vcluster.loft.sh/original-taints", + translate.ManagedLabelsAnnotation: "test", }, }, Status: corev1.NodeStatus{ @@ -186,12 +184,8 @@ func TestSync(t *testing.T) { baseNode = &corev1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: baseName.Name, - Labels: map[string]string{ - "kubernetes.io/hostname": GetNodeHost(baseName.Name), - }, Annotations: map[string]string{ - translate.ManagedLabelsAnnotation: "kubernetes.io/hostname", - TaintsAnnotation: "[\"{\\\"key\\\":\\\"key1\\\",\\\"value\\\":\\\"value1\\\",\\\"effect\\\":\\\"NoSchedule\\\"}\"]", + TaintsAnnotation: "[\"{\\\"key\\\":\\\"key1\\\",\\\"value\\\":\\\"value1\\\",\\\"effect\\\":\\\"NoSchedule\\\"}\"]", }, }, Spec: corev1.NodeSpec{ @@ -224,12 +218,8 @@ func TestSync(t *testing.T) { editedNode = &corev1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: baseName.Name, - Labels: map[string]string{ - "kubernetes.io/hostname": GetNodeHost(baseName.Name), - }, Annotations: map[string]string{ - translate.ManagedLabelsAnnotation: "kubernetes.io/hostname", - TaintsAnnotation: "[\"{\\\"key\\\":\\\"key1\\\",\\\"value\\\":\\\"value1\\\",\\\"effect\\\":\\\"NoSchedule\\\"}\"]", + TaintsAnnotation: "[\"{\\\"key\\\":\\\"key1\\\",\\\"value\\\":\\\"value1\\\",\\\"effect\\\":\\\"NoSchedule\\\"}\"]", }, }, Spec: corev1.NodeSpec{ @@ -355,8 +345,7 @@ func TestSync(t *testing.T) { translate.ManagedLabelsAnnotation: "test", }, Labels: map[string]string{ - "test": "true", - "kubernetes.io/hostname": GetNodeHost(baseName.Name), + "test": "true", }, }, Status: corev1.NodeStatus{ @@ -497,8 +486,7 @@ func TestSync(t *testing.T) { translate.ManagedLabelsAnnotation: "test", }, Labels: map[string]string{ - "test": "true", - "kubernetes.io/hostname": GetNodeHost(baseName.Name), + "test": "true", }, }, Status: corev1.NodeStatus{ @@ -545,8 +533,7 @@ func TestSync(t *testing.T) { translate.ManagedLabelsAnnotation: "test", }, Labels: map[string]string{ - "test": "true", - "kubernetes.io/hostname": GetNodeHost(baseName.Name), + "test": "true", }, }, Status: corev1.NodeStatus{ diff --git a/pkg/controllers/resources/nodes/translate.go b/pkg/controllers/resources/nodes/translate.go index aa582a292..87860cd40 100644 --- a/pkg/controllers/resources/nodes/translate.go +++ b/pkg/controllers/resources/nodes/translate.go @@ -100,10 +100,6 @@ func (s *nodeSyncer) translateUpdateBackwards(pNode *corev1.Node, vNode *corev1. } } - if s.useFakeKubelets { - labels["kubernetes.io/hostname"] = GetNodeHost(vNode.Name) - } - // Omit those taints for which the vcluster has enforced tolerations defined if len(s.enforcedTolerations) > 0 && len(translatedSpec.Taints) > 0 { translatedSpec.Taints = s.filterOutTaintsMatchingTolerations(translatedSpec.Taints) diff --git a/test/e2e_node/node.go b/test/e2e_node/node.go index 0fb1f326e..1ba7be0fe 100644 --- a/test/e2e_node/node.go +++ b/test/e2e_node/node.go @@ -21,15 +21,11 @@ var _ = ginkgo.Describe("Node sync", func() { hostNodeLabels := make(map[string]map[string]string) for _, node := range hostNodes.Items { - pHostname := node.Labels[corev1.LabelHostname] - pHostname += ".nodes.vcluster.com" - node.Labels[corev1.LabelHostname] = pHostname hostNodeLabels[node.Name] = node.Labels } virtualNodeLabels := make(map[string]map[string]string) for _, node := range virtualNodes.Items { - delete(node.Labels, "vcluster.loft.sh/fake-node") virtualNodeLabels[node.Name] = node.Labels }