@@ -20,6 +20,7 @@ import (
2020
2121const (
2222 maxFirewallRuleLabelLen = 32
23+ maxFirewallRuleDescLen = 100
2324 maxIPsPerFirewall = 255
2425 maxRulesPerFirewall = 25
2526)
@@ -205,10 +206,16 @@ func processACL(fwcreateOpts *linodego.FirewallCreateOptions, aclType, label, sv
205206 ipv4chunks := chunkIPs (ipv4s )
206207 for i , chunk := range ipv4chunks {
207208 v4chunk := chunk
209+ desc := fmt .Sprintf ("Rule %d, Created by linode-ccm: %s, for %s" , i , label , svcName )
210+ if len (desc ) > maxFirewallRuleDescLen {
211+ newDesc := desc [0 :maxFirewallRuleDescLen - 3 ] + "..."
212+ klog .Infof ("Firewall rule description '%s' is too long. Stripping it to '%s'" , desc , newDesc )
213+ desc = newDesc
214+ }
208215 fwcreateOpts .Rules .Inbound = append (fwcreateOpts .Rules .Inbound , linodego.FirewallRule {
209216 Action : aclType ,
210217 Label : ruleLabel ,
211- Description : fmt . Sprintf ( "Rule %d, Created by linode-ccm: %s, for %s" , i , label , svcName ) ,
218+ Description : desc ,
212219 Protocol : linodego .TCP , // Nodebalancers support only TCP.
213220 Ports : ports ,
214221 Addresses : linodego.NetworkAddresses {IPv4 : & v4chunk },
@@ -218,20 +225,32 @@ func processACL(fwcreateOpts *linodego.FirewallCreateOptions, aclType, label, sv
218225 ipv6chunks := chunkIPs (ipv6s )
219226 for i , chunk := range ipv6chunks {
220227 v6chunk := chunk
228+ desc := fmt .Sprintf ("Rule %d, Created by linode-ccm: %s, for %s" , i , label , svcName )
229+ if len (desc ) > maxFirewallRuleDescLen {
230+ newDesc := desc [0 :maxFirewallRuleDescLen - 3 ] + "..."
231+ klog .Infof ("Firewall rule description '%s' is too long. Stripping it to '%s'" , desc , newDesc )
232+ desc = newDesc
233+ }
221234 fwcreateOpts .Rules .Inbound = append (fwcreateOpts .Rules .Inbound , linodego.FirewallRule {
222235 Action : aclType ,
223236 Label : ruleLabel ,
224- Description : fmt . Sprintf ( "Rule %d, Created by linode-ccm: %s, for %s" , i , label , svcName ) ,
237+ Description : desc ,
225238 Protocol : linodego .TCP , // Nodebalancers support only TCP.
226239 Ports : ports ,
227240 Addresses : linodego.NetworkAddresses {IPv6 : & v6chunk },
228241 })
229242 }
230243 } else {
244+ desc := fmt .Sprintf ("Created by linode-ccm: %s, for %s" , label , svcName )
245+ if len (desc ) > maxFirewallRuleDescLen {
246+ newDesc := desc [0 :maxFirewallRuleDescLen - 3 ] + "..."
247+ klog .Infof ("Firewall rule description '%s' is too long. Stripping it to '%s'" , desc , newDesc )
248+ desc = newDesc
249+ }
231250 fwcreateOpts .Rules .Inbound = append (fwcreateOpts .Rules .Inbound , linodego.FirewallRule {
232251 Action : aclType ,
233252 Label : ruleLabel ,
234- Description : fmt . Sprintf ( "Created by linode-ccm: %s, for %s" , label , svcName ) ,
253+ Description : desc ,
235254 Protocol : linodego .TCP , // Nodebalancers support only TCP.
236255 Ports : ports ,
237256 Addresses : ips ,
@@ -453,7 +472,7 @@ func (l *LinodeClient) updateNodeBalancerFirewallWithACL(
453472 return nil
454473 }
455474
456- fwCreateOpts , err := CreateFirewallOptsForSvc (service . Name , []string {"" }, service )
475+ fwCreateOpts , err := CreateFirewallOptsForSvc (firewalls [ 0 ]. Label , []string {"" }, service )
457476 if err != nil {
458477 return err
459478 }
0 commit comments