From 9f028a7766e0bf67fb7170bd4f2483ecc8577578 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Wed, 16 Feb 2022 13:19:08 +0530 Subject: [PATCH] Adding more addresses to the machine spec --- cloud/scope/powervs_machine.go | 13 +++++++++++-- controllers/ibmpowervsmachine_controller.go | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cloud/scope/powervs_machine.go b/cloud/scope/powervs_machine.go index 85c82fe7e..d9c964f58 100644 --- a/cloud/scope/powervs_machine.go +++ b/cloud/scope/powervs_machine.go @@ -360,9 +360,18 @@ func (m *PowerVSMachineScope) SetHealth(health *models.PVMInstanceHealth) { } } -func (m *PowerVSMachineScope) SetAddresses(networks []*models.PVMInstanceNetwork) { +func (m *PowerVSMachineScope) SetAddresses(instance *models.PVMInstance) { var addresses []corev1.NodeAddress - for _, network := range networks { + // Setting the name of the vm to the InternalDNS and Hostname as the vm uses that as hostname + addresses = append(addresses, corev1.NodeAddress{ + Type: corev1.NodeInternalDNS, + Address: *instance.ServerName, + }) + addresses = append(addresses, corev1.NodeAddress{ + Type: corev1.NodeHostName, + Address: *instance.ServerName, + }) + for _, network := range instance.Networks { addresses = append(addresses, corev1.NodeAddress{ Type: corev1.NodeInternalIP, Address: network.IPAddress, diff --git a/controllers/ibmpowervsmachine_controller.go b/controllers/ibmpowervsmachine_controller.go index 20307c2bb..bdc93f454 100644 --- a/controllers/ibmpowervsmachine_controller.go +++ b/controllers/ibmpowervsmachine_controller.go @@ -206,7 +206,7 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(ctx context.Context, machi return ctrl.Result{}, err } machineScope.SetInstanceID(instance.PvmInstanceID) - machineScope.SetAddresses(instance.Networks) + machineScope.SetAddresses(instance) machineScope.SetHealth(instance.Health) machineScope.SetInstanceState(instance.Status) switch machineScope.GetInstanceState() {