@@ -129,7 +129,7 @@ func (m *ManagedMachinePoolScope) SetReplicaCount(count int32) {
129129// GetWorkerMachineSubnet returns the WorkerRole core.Subnet id for the cluster
130130func (m * ManagedMachinePoolScope ) GetWorkerMachineSubnet () * string {
131131 for _ , subnet := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .Subnets {
132- if subnet .Role == infrastructurev1beta2 .WorkerRole {
132+ if subnet != nil && subnet .Role == infrastructurev1beta2 .WorkerRole {
133133 return subnet .ID
134134 }
135135 }
@@ -140,7 +140,7 @@ func (m *ManagedMachinePoolScope) GetWorkerMachineSubnet() *string {
140140func (m * ManagedMachinePoolScope ) SetListandSetMachinePoolInstances (ctx context.Context , nodePool * oke.NodePool ) (int32 , error ) {
141141 providerIDList := make ([]string , 0 )
142142 for _ , instance := range nodePool .Nodes {
143- if instance .LifecycleState == oke .NodeLifecycleStateActive {
143+ if instance .Id != nil && instance . LifecycleState == oke .NodeLifecycleStateActive {
144144 providerIDList = append (providerIDList , * instance .Id )
145145 }
146146 }
@@ -484,7 +484,7 @@ func (m *ManagedMachinePoolScope) getFreeFormTags() map[string]string {
484484func (m * ManagedMachinePoolScope ) getWorkerMachineSubnets () []string {
485485 subnetList := make ([]string , 0 )
486486 for _ , subnet := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .Subnets {
487- if subnet .Role == infrastructurev1beta2 .WorkerRole {
487+ if subnet != nil && subnet .Role == infrastructurev1beta2 .WorkerRole {
488488 subnetList = append (subnetList , subnet .Name )
489489 }
490490 }
@@ -497,14 +497,14 @@ func (m *ManagedMachinePoolScope) getWorkerMachineNSGs() []string {
497497 if len (specNsgNames ) > 0 {
498498 for _ , nsgName := range specNsgNames {
499499 for _ , nsg := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .NetworkSecurityGroup .List {
500- if nsg .Name == nsgName {
500+ if nsg != nil && nsg . ID != nil && nsg .Name == nsgName {
501501 nsgList = append (nsgList , * nsg .ID )
502502 }
503503 }
504504 }
505505 } else {
506506 for _ , nsg := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .NetworkSecurityGroup .List {
507- if nsg .Role == infrastructurev1beta2 .WorkerRole {
507+ if nsg != nil && nsg . ID != nil && nsg .Role == infrastructurev1beta2 .WorkerRole {
508508 nsgList = append (nsgList , * nsg .ID )
509509 }
510510 }
@@ -515,7 +515,7 @@ func (m *ManagedMachinePoolScope) getWorkerMachineNSGs() []string {
515515func (m * ManagedMachinePoolScope ) getWorkerMachineNSGList () []string {
516516 nsgList := make ([]string , 0 )
517517 for _ , nsg := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .NetworkSecurityGroup .List {
518- if nsg .Role == infrastructurev1beta2 .WorkerRole {
518+ if nsg != nil && nsg .Role == infrastructurev1beta2 .WorkerRole {
519519 nsgList = append (nsgList , nsg .Name )
520520 }
521521 }
@@ -527,7 +527,7 @@ func (m *ManagedMachinePoolScope) getPodSubnets(subnets []string) []string {
527527 if len (subnets ) > 0 {
528528 for _ , subnetName := range subnets {
529529 for _ , subnet := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .Subnets {
530- if subnet .Name == subnetName {
530+ if subnet != nil && subnet . ID != nil && subnet .Name == subnetName {
531531 subnetList = append (subnetList , * subnet .ID )
532532 }
533533 }
@@ -541,7 +541,7 @@ func (m *ManagedMachinePoolScope) getPodNSGs(nsgs []string) []string {
541541 if len (nsgs ) > 0 {
542542 for _ , nsgName := range nsgs {
543543 for _ , nsg := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .NetworkSecurityGroup .List {
544- if nsg .Name == nsgName {
544+ if nsg != nil && nsg . ID != nil && nsg .Name == nsgName {
545545 nsgList = append (nsgList , * nsg .ID )
546546 }
547547 }
@@ -581,7 +581,7 @@ func (m *ManagedMachinePoolScope) getInitialNodeKeyValuePairs() []oke.KeyValue {
581581
582582func (m * ManagedMachinePoolScope ) getWorkerMachineSubnet (name * string ) * string {
583583 for _ , subnet := range m .OCIManagedCluster .Spec .NetworkSpec .Vcn .Subnets {
584- if subnet .Name == * name {
584+ if subnet != nil && subnet . ID != nil && subnet .Name == * name {
585585 return subnet .ID
586586 }
587587 }
0 commit comments