From 78e47deda47371959d7b40c02bfc55ec3ca21bcb Mon Sep 17 00:00:00 2001 From: Vivek Aggarwal Date: Wed, 30 Jan 2019 10:50:59 -0800 Subject: [PATCH] CNI Update operation support --- cns/networkcontainers/networkcontainers.go | 3 --- network/endpoint.go | 2 +- network/endpoint_test.go | 24 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 network/endpoint_test.go diff --git a/cns/networkcontainers/networkcontainers.go b/cns/networkcontainers/networkcontainers.go index e1b37367a0..d4633dd863 100644 --- a/cns/networkcontainers/networkcontainers.go +++ b/cns/networkcontainers/networkcontainers.go @@ -77,9 +77,6 @@ func (cn *NetworkContainers) Create(createNetworkContainerRequest cns.CreateNetw func (cn *NetworkContainers) Update(createNetworkContainerRequest cns.CreateNetworkContainerRequest, netpluginConfig *NetPluginConfiguration) error { log.Printf("[Azure CNS] NetworkContainers.Update called") err := updateInterface(createNetworkContainerRequest, netpluginConfig) - if err == nil { - err = setWeakHostOnInterface(createNetworkContainerRequest.PrimaryInterfaceIdentifier) - } log.Printf("[Azure CNS] NetworkContainers.Update finished.") return err } diff --git a/network/endpoint.go b/network/endpoint.go index b7c44e584d..cbff7cbeab 100644 --- a/network/endpoint.go +++ b/network/endpoint.go @@ -171,7 +171,7 @@ func podNameMatches(source string, actualValue string, doExactMatch bool) bool { } else { // If exact match flag is disabled we just check if the existing podname field for an endpoint // starts with passed podname string. - return (source == GetPodNameWithoutSuffix(actualValue)) + return (actualValue == GetPodNameWithoutSuffix(source)) } } diff --git a/network/endpoint_test.go b/network/endpoint_test.go new file mode 100644 index 0000000000..4a07a2ff0a --- /dev/null +++ b/network/endpoint_test.go @@ -0,0 +1,24 @@ +// Copyright 2019 Microsoft. All rights reserved. +// MIT License + +package network + +import ( + "testing" +) + +func TestGetPodName(t *testing.T) { + testData := map[string]string{ + "nginx-deployment-5c689d88bb": "nginx", + "nginx-deployment-5c689d88bb-qwq47": "nginx-deployment", + "nginx": "nginx", + } + + for testValue, expectedPodName := range testData { + podName := GetPodNameWithoutSuffix(testValue) + + if podName != expectedPodName { + t.Error("Expected:", expectedPodName, ", Got: ", podName, ", For Test Value:", testValue) + } + } +}