Skip to content

Commit

Permalink
Merge pull request #211 from dulek/master
Browse files Browse the repository at this point in the history
Sync from upstream
  • Loading branch information
openshift-merge-robot committed Aug 16, 2023
2 parents dc785bc + 42c95f4 commit 7b52ba5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/openstack/loadbalancer.go
Expand Up @@ -2156,7 +2156,7 @@ func (lbaas *LbaasV2) UpdateLoadBalancer(ctx context.Context, clusterName string

func compareSecurityGroupRuleAndCreateOpts(rule rules.SecGroupRule, opts rules.CreateOpts) bool {
return rule.Direction == string(opts.Direction) &&
rule.Protocol == string(opts.Protocol) &&
strings.EqualFold(rule.Protocol, string(opts.Protocol)) &&
rule.EtherType == string(opts.EtherType) &&
rule.RemoteIPPrefix == opts.RemoteIPPrefix &&
rule.PortRangeMin == opts.PortRangeMin &&
Expand Down Expand Up @@ -2282,10 +2282,11 @@ func (lbaas *LbaasV2) ensureAndUpdateOctaviaSecurityGroup(clusterName string, ap
continue
}
for _, cidr := range cidrs {
protocol := strings.ToLower(string(port.Protocol)) // K8s uses TCP, Neutron uses tcp, etc.
wantedRules = append(wantedRules,
rules.CreateOpts{
Direction: rules.DirIngress,
Protocol: rules.RuleProtocol(port.Protocol),
Protocol: rules.RuleProtocol(protocol),
EtherType: etherType,
RemoteIPPrefix: cidr,
SecGroupID: lbSecGroupID,
Expand Down
28 changes: 28 additions & 0 deletions pkg/openstack/loadbalancer_test.go
Expand Up @@ -207,6 +207,34 @@ func TestGetRulesToCreateAndDelete(t *testing.T) {
},
},
},
{
testName: "Protocol case mismatch",
wantedRules: []rules.CreateOpts{
{
Direction: "ingress",
EtherType: "IPv4",
SecGroupID: "foo",
PortRangeMax: 123,
PortRangeMin: 123,
Protocol: "TCP",
RemoteIPPrefix: "10.0.0.0/8",
},
},
existingRules: []rules.SecGroupRule{
{
ID: "bar",
Direction: "ingress",
EtherType: "IPv4",
SecGroupID: "foo",
PortRangeMax: 123,
PortRangeMin: 123,
Protocol: "tcp",
RemoteIPPrefix: "10.0.0.0/8",
},
},
toCreate: []rules.CreateOpts{},
toDelete: []rules.SecGroupRule{},
},
{
testName: "changing a port number",
wantedRules: []rules.CreateOpts{
Expand Down

0 comments on commit 7b52ba5

Please sign in to comment.