From c45b2d9d7a16e199cbf3af871c36d8bf7c0e9f6b Mon Sep 17 00:00:00 2001 From: Aman Shrivastava Date: Wed, 20 Nov 2024 19:02:48 +0530 Subject: [PATCH] Fetch service instance id from spec of IBMPowerVSCluster object --- cloud/scope/powervs_machine.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cloud/scope/powervs_machine.go b/cloud/scope/powervs_machine.go index 9ffc38667..e136cc11a 100644 --- a/cloud/scope/powervs_machine.go +++ b/cloud/scope/powervs_machine.go @@ -922,10 +922,16 @@ func (m *PowerVSMachineScope) GetZone() string { // GetServiceInstanceID returns the service instance id. func (m *PowerVSMachineScope) GetServiceInstanceID() string { - if m.IBMPowerVSCluster.Status.ServiceInstance == nil || m.IBMPowerVSCluster.Status.ServiceInstance.ID == nil { - return "" + if m.IBMPowerVSCluster.Status.ServiceInstance != nil && m.IBMPowerVSCluster.Status.ServiceInstance.ID != nil { + return *m.IBMPowerVSCluster.Status.ServiceInstance.ID + } + if m.IBMPowerVSCluster.Spec.ServiceInstanceID != "" { + return m.IBMPowerVSCluster.Spec.ServiceInstanceID } - return *m.IBMPowerVSCluster.Status.ServiceInstance.ID + if m.IBMPowerVSCluster.Spec.ServiceInstance != nil && m.IBMPowerVSCluster.Spec.ServiceInstance.ID != nil { + return *m.IBMPowerVSCluster.Spec.ServiceInstance.ID + } + return "" } // SetProviderID will set the provider id for the machine.