Skip to content

Commit

Permalink
Fix: add nil check on Machine and Network Load Balancer (#349)
Browse files Browse the repository at this point in the history
* add: subnet id nil check on network load balancer
  • Loading branch information
tozastation committed Feb 8, 2024
1 parent 3e14e22 commit 8acfb46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ func (m *MachineScope) getGetControlPlaneMachineNSGs() []string {
nsgs := make([]string, 0)
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
if nsg.Role == infrastructurev1beta2.ControlPlaneRole {
nsgs = append(nsgs, *nsg.ID)
if nsg.ID != nil {
nsgs = append(nsgs, *nsg.ID)
}
}
}
return nsgs
Expand Down Expand Up @@ -771,7 +773,9 @@ func (m *MachineScope) getWorkerMachineNSGs() []string {
for _, nsgName := range m.OCIMachine.Spec.NetworkDetails.NsgNames {
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
if nsg.Name == nsgName {
nsgs = append(nsgs, *nsg.ID)
if nsg.ID != nil {
nsgs = append(nsgs, *nsg.ID)
}
}
}
}
Expand All @@ -780,7 +784,9 @@ func (m *MachineScope) getWorkerMachineNSGs() []string {
nsgs := make([]string, 0)
for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List {
if nsg.Role == infrastructurev1beta2.WorkerRole {
nsgs = append(nsgs, *nsg.ID)
if nsg.ID != nil {
nsgs = append(nsgs, *nsg.ID)
}
}
}
return nsgs
Expand Down
4 changes: 3 additions & 1 deletion cloud/scope/network_load_balancer_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ func (s *ClusterScope) CreateNLB(ctx context.Context, lb infrastructurev1beta2.L
var controlPlaneEndpointSubnets []string
for _, subnet := range s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets {
if subnet.Role == infrastructurev1beta2.ControlPlaneEndpointRole {
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, *subnet.ID)
if subnet.ID != nil {
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, *subnet.ID)
}
}
}
if len(controlPlaneEndpointSubnets) < 1 {
Expand Down

0 comments on commit 8acfb46

Please sign in to comment.