Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Default to allow-all if no allowed CIDRs are defined #55

Merged
merged 1 commit into from
Oct 2, 2024
Merged
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
5 changes: 3 additions & 2 deletions cloudstack/cloudstack_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,9 @@ func rulesMapToString(rules map[*cloudstack.FirewallRule]bool) string {
//
// Returns true if the firewall rule was created or updated.
func (lb *loadBalancer) updateFirewallRule(publicIPID string, publicPort int, protocol LoadBalancerProtocol, allowedCIDRs []string) (bool, error) {
// Default to allow-all if no allowed CIDRs are defined.
if len(allowedCIDRs) == 0 {
return false, errors.New("the allowed CIDR list cannot be empty")
allowedCIDRs = []string{defaultAllowedCIDR}
}

p := lb.Firewall.NewListFirewallRulesParams()
Expand Down Expand Up @@ -919,7 +920,6 @@ func getLoadBalancerSourceRanges(service *corev1.Service) (utilnet.IPNetSet, err
if len(service.Spec.LoadBalancerSourceRanges) > 0 {
specs := service.Spec.LoadBalancerSourceRanges
ipnets, err = utilnet.ParseIPNets(specs...)

if err != nil {
return nil, fmt.Errorf("service.Spec.LoadBalancerSourceRanges: %v is not valid. Expecting a list of IP ranges. For example, 10.0.0.0/24. Error msg: %v", specs, err)
}
Expand All @@ -935,6 +935,7 @@ func getLoadBalancerSourceRanges(service *corev1.Service) (utilnet.IPNetSet, err
return nil, fmt.Errorf("%s: %s is not valid. Expecting a comma-separated list of source IP ranges. For example, 10.0.0.0/24,192.168.2.0/24", corev1.AnnotationLoadBalancerSourceRangesKey, val)
}
}

return ipnets, nil
}

Expand Down