diff --git a/pkg/cloudprovider/securitygroup.go b/pkg/cloudprovider/securitygroup.go index f110f2ef90..ca6c402c0d 100644 --- a/pkg/cloudprovider/securitygroup.go +++ b/pkg/cloudprovider/securitygroup.go @@ -125,9 +125,6 @@ func AddDefaultRule(rules []SecurityRule, defaultRule SecurityRule, localRuleStr defaultRule.Priority = max } defaultRule.Priority -= int(order) - if onlyAllowRules { - defaultRule.Priority = -1 - } return append(rules, defaultRule) } diff --git a/pkg/compute/regiondrivers/aws.go b/pkg/compute/regiondrivers/aws.go index 5eb678ee90..d57103181a 100644 --- a/pkg/compute/regiondrivers/aws.go +++ b/pkg/compute/regiondrivers/aws.go @@ -60,7 +60,7 @@ func (self *SAwsRegionDriver) GetDefaultSecurityGroupInRule() cloudprovider.Secu } func (self *SAwsRegionDriver) GetDefaultSecurityGroupOutRule() cloudprovider.SecurityRule { - return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("out:allow any")} + return cloudprovider.SecurityRule{SecurityRule: *secrules.MustParseSecurityRule("out:deny any")} } func (self *SAwsRegionDriver) GetSecurityGroupRuleMaxPriority() int { diff --git a/pkg/compute/regiondrivers/secgroup_aws_test.go b/pkg/compute/regiondrivers/secgroup_aws_test.go index c698eb5782..c4d5bd6b27 100644 --- a/pkg/compute/regiondrivers/secgroup_aws_test.go +++ b/pkg/compute/regiondrivers/secgroup_aws_test.go @@ -34,7 +34,7 @@ func TestAwsRuleSync(t *testing.T) { data := []TestData{ { - Name: "Test out deny rules", + Name: "Test remove out allow rules", LocalRules: secrules.SecurityRuleSet{ localRuleWithPriority("out:deny any", 1), }, @@ -49,6 +49,30 @@ func TestAwsRuleSync(t *testing.T) { remoteRuleWithName("", "out:allow any", 1), }, }, + { + Name: "Test out deny rules", + LocalRules: secrules.SecurityRuleSet{ + localRuleWithPriority("out:deny any", 1), + }, + RemoteRules: []cloudprovider.SecurityRule{}, + Common: []cloudprovider.SecurityRule{}, + InAdds: []cloudprovider.SecurityRule{}, + OutAdds: []cloudprovider.SecurityRule{}, + InDels: []cloudprovider.SecurityRule{}, + OutDels: []cloudprovider.SecurityRule{}, + }, + { + Name: "Test out allow rules", + LocalRules: secrules.SecurityRuleSet{}, + RemoteRules: []cloudprovider.SecurityRule{}, + Common: []cloudprovider.SecurityRule{}, + InAdds: []cloudprovider.SecurityRule{}, + OutAdds: []cloudprovider.SecurityRule{ + remoteRuleWithName("", "out:allow any", 0), + }, + InDels: []cloudprovider.SecurityRule{}, + OutDels: []cloudprovider.SecurityRule{}, + }, } for _, d := range data {