Skip to content

Commit 677f4dd

Browse files
committed
delete legacy denyall acls when upgrading to v1.13.x (#4742)
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]>
1 parent a80490a commit 677f4dd

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/ovs/ovn-nb-acl.go

+26
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,32 @@ func (c *OVNNbClient) CreateNodeACL(pgName, nodeIPStr, joinIPStr string) error {
277277
func (c *OVNNbClient) CreateSgDenyAllACL(sgName string) error {
278278
pgName := GetSgPortGroupName(sgName)
279279

280+
// for upgrading from v1.12.x to v1.13.x
281+
// see https://github.com/kubeovn/kube-ovn/issues/4742
282+
oldIngressACL, err := c.GetACL(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName), true)
283+
if err != nil {
284+
klog.Error(err)
285+
return err
286+
}
287+
if oldIngressACL != nil && oldIngressACL.Tier == util.DefaultACLTier {
288+
if err := c.DeleteACL(pgName, portGroupKey, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName)); err != nil {
289+
klog.Errorf("delete legacy acl from port group %s: %v", pgName, err)
290+
return err
291+
}
292+
}
293+
oldEgressACL, err := c.GetACL(pgName, ovnnb.ACLDirectionFromLport, util.SecurityGroupDropPriority, fmt.Sprintf("inport == @%s && ip", pgName), true)
294+
if err != nil {
295+
klog.Error(err)
296+
return err
297+
}
298+
if oldEgressACL != nil && oldEgressACL.Tier == util.DefaultACLTier {
299+
if err := c.DeleteACL(pgName, portGroupKey, ovnnb.ACLDirectionFromLport, util.SecurityGroupDropPriority, fmt.Sprintf("inport == @%s && ip", pgName)); err != nil {
300+
klog.Errorf("delete legacy acl from port group %s: %v", pgName, err)
301+
return err
302+
}
303+
}
304+
305+
// create new acls for deny all sg
280306
ingressACL, err := c.newACL(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName), ovnnb.ACLActionDrop, util.NetpolACLTier)
281307
if err != nil {
282308
klog.Error(err)

pkg/util/const.go

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const (
157157
AnpMaxPriority = 99
158158
AnpACLMaxPriority = 30000
159159
BanpACLMaxPriority = 1800
160+
DefaultACLTier = 0
160161
AnpACLTier = 1
161162
NetpolACLTier = 2
162163
BanpACLTier = 3

0 commit comments

Comments
 (0)