Skip to content

Commit

Permalink
Create all existing ACLs in tier2
Browse files Browse the repository at this point in the history
We have a new feature called Hierarchical
ACLs that is introduced in OVN to enable
support for tiered ACLs. This commit ensures
that from this point on, all ACLs for all features
are created in tier2. By default all
new ACLs must be added to tier2.

Ensure existing ACLs without tiers are migrated post upgrade

Since the column in NBDB is an int,
when OVN schema upgrade happens, by default
the value for this column will be set to 0.

We want all existing ACLs to move to tier2.
This commit ensures all existing ACLs for
all features are migrated towards tier2.
This PR ensures that is done by OVNK controller
upon upgrade restart.

Signed-off-by: Surya Seetharaman <[email protected]>
  • Loading branch information
tssurya committed Jun 14, 2023
1 parent 69d205a commit a8e2275
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 10 deletions.
6 changes: 4 additions & 2 deletions go-controller/pkg/libovsdbops/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package libovsdbops
import (
"context"
"fmt"

libovsdbclient "github.com/ovn-org/libovsdb/client"
libovsdb "github.com/ovn-org/libovsdb/ovsdb"

Expand All @@ -21,7 +22,7 @@ func GetACLName(acl *nbdb.ACL) string {

func getACLMutableFields(acl *nbdb.ACL) []interface{} {
return []interface{}{&acl.Action, &acl.Direction, &acl.ExternalIDs, &acl.Log, &acl.Match, &acl.Meter,
&acl.Name, &acl.Options, &acl.Priority, &acl.Severity}
&acl.Name, &acl.Options, &acl.Priority, &acl.Severity, &acl.Tier}
}

type aclPredicate func(*nbdb.ACL) bool
Expand Down Expand Up @@ -63,7 +64,7 @@ func FindACLs(nbClient libovsdbclient.Client, acls []*nbdb.ACL) ([]*nbdb.ACL, er

// BuildACL builds an ACL with empty optional properties unset
func BuildACL(name string, direction nbdb.ACLDirection, priority int, match string, action nbdb.ACLAction, meter string,
severity nbdb.ACLSeverity, log bool, externalIds map[string]string, options map[string]string) *nbdb.ACL {
severity nbdb.ACLSeverity, log bool, externalIds map[string]string, options map[string]string, tier int) *nbdb.ACL {
name = fmt.Sprintf("%.63s", name)

var realName *string
Expand All @@ -89,6 +90,7 @@ func BuildACL(name string, direction nbdb.ACLDirection, priority int, match stri
Meter: realMeter,
ExternalIDs: externalIds,
Options: options,
Tier: tier,
}

return acl
Expand Down
17 changes: 17 additions & 0 deletions go-controller/pkg/libovsdbops/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ func TestCreateOrUpdateACL(t *testing.T) {
Severity: &aclSev,
},
},
{
desc: "updates Tiers to tier2",
initialACL: initialACL,
finalACL: &nbdb.ACL{
Action: nbdb.ACLActionAllow,
Direction: nbdb.ACLDirectionToLport,
ExternalIDs: nil,
Log: true,
Match: "match",
Meter: &aclMeter,
Name: &aclName,
Options: map[string]string{"key": "value"},
Priority: 1,
Severity: &aclSev,
Tier: 2, // default tier
},
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions go-controller/pkg/ovn/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func BuildACL(dbIDs *libovsdbops.DbObjectIDs, priority int, match, action string
log,
externalIDs,
options,
types.DefaultACLTier,
)
return ACL
}
Expand Down
17 changes: 17 additions & 0 deletions go-controller/pkg/ovn/egressfirewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
purgeIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
purgeACL.UUID = "purgeACL-UUID"
// no externalIDs present => dbIDs can't be built
Expand All @@ -157,6 +158,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
nil,
nil,
t.DefaultACLTier,
)
purgeACL2.UUID = "purgeACL2-UUID"

Expand Down Expand Up @@ -184,6 +186,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
updateIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
updateACL.UUID = "updateACL-UUID"

Expand All @@ -199,6 +202,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
nil,
nil,
t.DefaultACLTier,
)
ignoreACL.UUID = "ignoreACL-UUID"

Expand Down Expand Up @@ -290,6 +294,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -336,6 +341,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv6ACL.UUID = "ipv6ACL-UUID"

Expand Down Expand Up @@ -389,6 +395,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
udpACL.UUID = "udpACL-UUID"

Expand Down Expand Up @@ -436,6 +443,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -496,6 +504,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -613,6 +622,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -697,6 +707,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -782,6 +793,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -862,6 +874,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL.UUID = "ipv4ACL-UUID"

Expand Down Expand Up @@ -980,6 +993,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
acl.UUID = "ACL-UUID"

Expand Down Expand Up @@ -1029,6 +1043,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
dbIDs.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
acl.UUID = "acl-UUID"

Expand Down Expand Up @@ -1076,6 +1091,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
aclIDs1.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL1.UUID = "ipv4ACL1-UUID"

Expand All @@ -1091,6 +1107,7 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations", func() {
false,
aclIDs2.GetExternalIDs(),
nil,
t.DefaultACLTier,
)
ipv4ACL2.UUID = "ipv4ACL2-UUID"

Expand Down
Loading

0 comments on commit a8e2275

Please sign in to comment.