diff --git a/agent/ecscni/plugin_windows_test.go b/agent/ecscni/plugin_windows_test.go index 09826b46299..d719864a812 100644 --- a/agent/ecscni/plugin_windows_test.go +++ b/agent/ecscni/plugin_windows_test.go @@ -103,6 +103,9 @@ func TestSetupNSTimeout(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + // Override the maximum retry timeout for the tests + setupNSBackoffMax = setupNSBackoffMin + ecscniClient := NewClient("") libcniClient := mock_libcni.NewMockCNI(ctrl) ecscniClient.(*cniClient).libcni = libcniClient @@ -111,7 +114,7 @@ func TestSetupNSTimeout(t *testing.T) { // vpc-eni plugin will be called. libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(¤t.Result{}, errors.New("timeout")).Do( func(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) { - }).MaxTimes(3), + }).MaxTimes(setupNSMaxRetryCount), ) config := getNetworkConfig() diff --git a/agent/ecscni/types_windows.go b/agent/ecscni/types_windows.go index 029fc30d69b..46b0bbdb003 100644 --- a/agent/ecscni/types_windows.go +++ b/agent/ecscni/types_windows.go @@ -28,12 +28,16 @@ const ( ECSVPCENIPluginExecutable = "vpc-eni.exe" // ECSBridgeNetworkName is the name of the HNS network used as ecs-bridge. ECSBridgeNetworkName = "nat" - // Constants for creating backoff while retrying setupNS. +) + +var ( + // Values for creating backoff while retrying setupNS. + // These have not been made constant so that we can inject different values for unit tests. setupNSBackoffMin = time.Second * 4 setupNSBackoffMax = time.Minute setupNSBackoffJitter = 0.2 - setupNSBackoffMultiple = 1.3 - setupNSMaxRetryCount = 3 + setupNSBackoffMultiple = 2.0 + setupNSMaxRetryCount = 5 ) // VPCENIPluginConfig contains all the information required to invoke the vpc-eni plugin.