File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -835,8 +835,12 @@ func (c *Controller) gcSecurityGroup() error {
835835 if pg .Name == denyAllPg || pg .Name == defaultPg || pg .ExternalIDs [networkPolicyKey ] != "" {
836836 continue
837837 }
838+ sg := pg .ExternalIDs [sgKey ]
839+ if sg == "" {
840+ continue
841+ }
838842 // if port group not exist in security group, delete it
839- if ! sgSet .Has (pg . ExternalIDs [ "sg" ] ) {
843+ if ! sgSet .Has (sg ) {
840844 klog .Infof ("ready to gc port group %s" , pg .Name )
841845 needToDelPgs = append (needToDelPgs , pg .Name )
842846 }
Original file line number Diff line number Diff line change 55
66 "github.com/scylladb/go-set/strset"
77 "github.com/stretchr/testify/require"
8+ "go.uber.org/mock/gomock"
89
10+ "github.com/kubeovn/kube-ovn/pkg/ovs"
911 "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb"
1012 "github.com/kubeovn/kube-ovn/pkg/util"
1113)
@@ -49,3 +51,21 @@ func Test_logicalRouterPortFilter(t *testing.T) {
4951 }
5052 }
5153}
54+
55+ func TestGcSecurityGroupSkipsVpcEgressGatewayPortGroup (t * testing.T ) {
56+ fakeController := newFakeController (t )
57+ ctrl := fakeController .fakeController
58+ mockOvnClient := fakeController .mockOvnClient
59+
60+ mockOvnClient .EXPECT ().ListPortGroups (map [string ]string {"vendor" : util .CniTypeName }).Return ([]ovnnb.PortGroup {{
61+ Name : "VEG.0b5177562709" ,
62+ ExternalIDs : map [string ]string {
63+ "af" : "4" ,
64+ ovs .ExternalIDVendor : util .CniTypeName ,
65+ ovs .ExternalIDVpcEgressGateway : "default/egress-ha-a" ,
66+ },
67+ }}, nil )
68+ mockOvnClient .EXPECT ().DeletePortGroup (gomock .Any ()).Times (0 )
69+
70+ require .NoError (t , ctrl .gcSecurityGroup ())
71+ }
You can’t perform that action at this time.
0 commit comments