Skip to content

Commit

Permalink
Revert "fix node labels syncing"
Browse files Browse the repository at this point in the history
  • Loading branch information
ishankhare07 authored Oct 9, 2023
1 parent 4358d23 commit 30b3fc4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/resources/nodes/fake_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/resources/nodes/fake_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
27 changes: 7 additions & 20 deletions pkg/controllers/resources/nodes/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
4 changes: 0 additions & 4 deletions pkg/controllers/resources/nodes/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions test/e2e_node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 30b3fc4

Please sign in to comment.