Skip to content

Commit

Permalink
Updated values for max retry during network setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh Rawat committed Jun 9, 2021
1 parent f8ff4dc commit 5b4a525
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion agent/ecscni/plugin_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(&current.Result{}, errors.New("timeout")).Do(
func(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) {
}).MaxTimes(3),
}).MaxTimes(setupNSMaxRetryCount),
)

config := getNetworkConfig()
Expand Down
10 changes: 7 additions & 3 deletions agent/ecscni/types_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5b4a525

Please sign in to comment.