Skip to content

Commit 8acfb46

Browse files
authored
Fix: add nil check on Machine and Network Load Balancer (#349)
* add: subnet id nil check on network load balancer
1 parent 3e14e22 commit 8acfb46

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Diff for: cloud/scope/machine.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,9 @@ func (m *MachineScope) getGetControlPlaneMachineNSGs() []string {
732732
nsgs := make([]string, 0)
733733
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
734734
if nsg.Role == infrastructurev1beta2.ControlPlaneRole {
735-
nsgs = append(nsgs, *nsg.ID)
735+
if nsg.ID != nil {
736+
nsgs = append(nsgs, *nsg.ID)
737+
}
736738
}
737739
}
738740
return nsgs
@@ -771,7 +773,9 @@ func (m *MachineScope) getWorkerMachineNSGs() []string {
771773
for _, nsgName := range m.OCIMachine.Spec.NetworkDetails.NsgNames {
772774
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
773775
if nsg.Name == nsgName {
774-
nsgs = append(nsgs, *nsg.ID)
776+
if nsg.ID != nil {
777+
nsgs = append(nsgs, *nsg.ID)
778+
}
775779
}
776780
}
777781
}
@@ -780,7 +784,9 @@ func (m *MachineScope) getWorkerMachineNSGs() []string {
780784
nsgs := make([]string, 0)
781785
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
782786
if nsg.Role == infrastructurev1beta2.WorkerRole {
783-
nsgs = append(nsgs, *nsg.ID)
787+
if nsg.ID != nil {
788+
nsgs = append(nsgs, *nsg.ID)
789+
}
784790
}
785791
}
786792
return nsgs

Diff for: cloud/scope/network_load_balancer_reconciler.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ func (s *ClusterScope) CreateNLB(ctx context.Context, lb infrastructurev1beta2.L
165165
var controlPlaneEndpointSubnets []string
166166
for _, subnet := range s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets {
167167
if subnet.Role == infrastructurev1beta2.ControlPlaneEndpointRole {
168-
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, *subnet.ID)
168+
if subnet.ID != nil {
169+
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, *subnet.ID)
170+
}
169171
}
170172
}
171173
if len(controlPlaneEndpointSubnets) < 1 {

0 commit comments

Comments
 (0)