From 934e359d102bde3b95d70e28ec108b1b11a3ff53 Mon Sep 17 00:00:00 2001 From: Maysa Macedo Date: Fri, 6 Oct 2023 11:55:42 -0300 Subject: [PATCH] UPSTREAM 1715: Add server name for the Machine InternalDNS For a node to join the cluster, a CSR generated by kubelet with the node name must be approved. The approval happens if the value of the NodeInternalDNS entry on the Machine matches the node name. When using legacy cloud provider the value of that node name is the Server name. This commit ensures the nodes handled with legacy cloud provides get approved by adding the server name to the list of Machine addresses. (cherry picked from commit de8aaa481fef13c1d2da4b53d52511155a7a810c) --- controllers/openstackmachine_controller.go | 8 ++++++++ test/e2e/suites/e2e/e2e_test.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/controllers/openstackmachine_controller.go b/controllers/openstackmachine_controller.go index 3a3f3e0a02..a00a9033b5 100644 --- a/controllers/openstackmachine_controller.go +++ b/controllers/openstackmachine_controller.go @@ -356,6 +356,14 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope } addresses := instanceNS.Addresses() + + // For OpenShift and likely other systems, a node joins the cluster if the CSR generated by kubelet with the node name is approved. + // The approval happens if the Machine InternalDNS matches the node name. The in-tree provider used the server name for the node name. + // Let's add the server name as the InternalDNS to keep getting CSRs of nodes upgraded from in-tree provider approved. + addresses = append(addresses, corev1.NodeAddress{ + Type: corev1.NodeInternalDNS, + Address: instanceStatus.Name(), + }) openStackMachine.Status.Addresses = addresses switch instanceStatus.State() { diff --git a/test/e2e/suites/e2e/e2e_test.go b/test/e2e/suites/e2e/e2e_test.go index e7e5a0bbde..7ca787e470 100644 --- a/test/e2e/suites/e2e/e2e_test.go +++ b/test/e2e/suites/e2e/e2e_test.go @@ -415,6 +415,12 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { // All IP addresses on all ports should be reported in Addresses Expect(machine.Status.Addresses).To(ContainElements(seenAddresses)) + + // Expect an InternalDNS entry matching the name of the OpenStack server + Expect(machine.Status.Addresses).To(ContainElement(clusterv1.MachineAddress{ + Type: clusterv1.MachineInternalDNS, + Address: machine.Spec.InfrastructureRef.Name, + })) } }) })