Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,18 @@ func (r *OpenStackClusterReconciler) reconcileNetworkComponents(log logr.Logger,

netOpts := networks.ListOpts(openStackCluster.Spec.Network)
networkList, err := networkingService.GetNetworksByFilter(&netOpts)
if err != nil && len(networkList) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change really fix the nil reference in the bug?

<<<<<<< Updated upstream
if len(networkList) == 0 {
return errors.Errorf("failed to find any network: %v", err)
}
=======
>>>>>>> Stashed changes
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to check err is nil or not before checking networkList == 0.

return errors.Errorf("failed to find network: %v", err)
}
if len(networkList) == 0 {
return errors.Errorf("failed to find any network: %v", err)
}
if len(networkList) > 1 {
return errors.Errorf("failed to find only one network (result: %v): %v", networkList, err)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloud/services/networking/securitygroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
var defaultRules = []infrav1.SecurityGroupRule{
{
Direction: "egress",
Description: "Full open",
EtherType: "IPv4",
PortRangeMin: 0,
PortRangeMax: 0,
Expand All @@ -43,6 +44,7 @@ var defaultRules = []infrav1.SecurityGroupRule{
},
{
Direction: "egress",
Description: "Full open",
EtherType: "IPv6",
PortRangeMin: 0,
PortRangeMax: 0,
Expand Down