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 firewall label length being too long with large svc names #174

Merged
merged 1 commit into from
Feb 8, 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
14 changes: 13 additions & 1 deletion cloud/linode/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/linode/linodego"
)

const (
maxFirewallRuleLabelLen = 32
)

var (
errNoNodesAvailable = errors.New("No nodes available for nodebalancer")
errInvalidFWConfig = errors.New("Specify either an allowList or a denyList for a firewall")
Expand Down Expand Up @@ -757,14 +761,22 @@ func (l *loadbalancers) getLoadBalancerTags(_ context.Context, clusterName strin
if ok {
return append(tags, strings.Split(tagStr, ",")...)
}

return tags
}

// processACL takes the IPs, aclType, label etc and formats them into the passed linodego.FirewallCreateOptions pointer.
func processACL(fwcreateOpts *linodego.FirewallCreateOptions, aclType, label, svcName, ports string, ips linodego.NetworkAddresses) {
ruleLabel := fmt.Sprintf("%s-%s", aclType, svcName)
if len(ruleLabel) > maxFirewallRuleLabelLen {
newLabel := ruleLabel[0:maxFirewallRuleLabelLen]
klog.Infof("Firewall label '%s' is too long. Stripping to '%s'", ruleLabel, newLabel)
ruleLabel = newLabel
}

fwcreateOpts.Rules.Inbound = append(fwcreateOpts.Rules.Inbound, linodego.FirewallRule{
Action: aclType,
Label: fmt.Sprintf("%s-%s", aclType, svcName),
Label: ruleLabel,
Description: fmt.Sprintf("Created by linode-ccm: %s, for %s", label, svcName),
Protocol: linodego.TCP, // Nodebalancers support only TCP.
Ports: ports,
Expand Down
Loading