Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherrypick #377 into release-1.2 #378

Merged
merged 1 commit into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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