Skip to content

Commit

Permalink
delete legacy denyall acls when upgrading to v1.13.x (kubeovn#4742)
Browse files Browse the repository at this point in the history
the acls in v1.13.x are in tier 2 rather than tier 0 in v1.12.x, which
results that legacy denyall sg will drop all traffics if a pod bound a sg,
because acls in tier 0 have the higest priority. we should recreate acls
in denyall sg when upgrading to v1.13.x.

Signed-off-by: Rain Suo <[email protected]>
  • Loading branch information
hackerain committed Nov 27, 2024
1 parent a80490a commit 5e9f14c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/ovs/ovn-nb-acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,32 @@ func (c *OVNNbClient) CreateNodeACL(pgName, nodeIPStr, joinIPStr string) error {
func (c *OVNNbClient) CreateSgDenyAllACL(sgName string) error {
pgName := GetSgPortGroupName(sgName)

// for upgrading from v1.12.x to v1.13.x
// see https://github.com/kubeovn/kube-ovn/issues/4742
oldIngressACL, err := c.GetACL(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName), true)
if err != nil {
klog.Error(err)
return err
}
if oldIngressACL.Tier == util.DefaultACLTier {
if err := c.DeleteACL(pgName, portGroupKey, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName)); err != nil {
klog.Errorf("delete legacy acl from port group %s: %v", pgName, err)
return err
}
}
oldEgressACL, err := c.GetACL(pgName, ovnnb.ACLDirectionFromLport, util.SecurityGroupDropPriority, fmt.Sprintf("inport == @%s && ip", pgName), true)
if err != nil {
klog.Error(err)
return err
}
if oldEgressACL.Tier == util.DefaultACLTier {
if err := c.DeleteACL(pgName, portGroupKey, ovnnb.ACLDirectionFromLport, util.SecurityGroupDropPriority, fmt.Sprintf("inport == @%s && ip", pgName)); err != nil {
klog.Errorf("delete legacy acl from port group %s: %v", pgName, err)
return err
}
}

// create new acls for deny all sg
ingressACL, err := c.newACL(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName), ovnnb.ACLActionDrop, util.NetpolACLTier)
if err != nil {
klog.Error(err)
Expand Down
1 change: 1 addition & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const (
AnpMaxPriority = 99
AnpACLMaxPriority = 30000
BanpACLMaxPriority = 1800
DefaultACLTier = 0
AnpACLTier = 1
NetpolACLTier = 2
BanpACLTier = 3
Expand Down

0 comments on commit 5e9f14c

Please sign in to comment.