Skip to content

Commit

Permalink
Merge pull request #378 from freehan/neg-bug-fix-cherrypick
Browse files Browse the repository at this point in the history
cherrypick #377 into release-1.2
  • Loading branch information
freehan authored Jun 29, 2018
2 parents 657a85e + e40dd2e commit da79350
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/neg/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (manager *syncerManager) ensureDeleteNetworkEndpointGroup(name, zone string
return manager.cloud.DeleteNetworkEndpointGroup(name, zone)
}

// getSyncerKey encodes a service namespace, name and targetPort into a string key
// getSyncerKey encodes a service namespace, name, service port and targetPort into a string key
func getSyncerKey(namespace, name string, port int32, targetPort string) servicePort {
return servicePort{
namespace: namespace,
Expand Down
3 changes: 1 addition & 2 deletions pkg/neg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ func (p1 PortNameMap) Union(p2 PortNameMap) PortNameMap {
func (p1 PortNameMap) Difference(p2 PortNameMap) PortNameMap {
result := make(PortNameMap)
for svcPort, targetPort := range p1 {
if _, ok := p2[svcPort]; !ok {
if p1[svcPort] != p2[svcPort] {
result[svcPort] = targetPort
}
}

return result
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/neg/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ func TestPortNameMapDifference(t *testing.T) {
PortNameMap{80: "namedport", 8080: "9000"},
PortNameMap{443: "3000", 5000: "6000"},
},
{
"difference of two non-empty maps with a key in common but different in value",
PortNameMap{80: "namedport"},
PortNameMap{80: "8080", 8080: "9000"},
PortNameMap{80: "namedport"},
},
{
"difference of two non-empty maps with 2 keys in common but different in values",
PortNameMap{80: "namedport", 443: "8443"},
PortNameMap{80: "8080", 443: "9443"},
PortNameMap{80: "namedport", 443: "8443"},
},
}

for _, tc := range testcases {
Expand Down

0 comments on commit da79350

Please sign in to comment.