Repository: firecracker-microvm/firecracker-containerd
Pull request #690 (2022-06-27 18:51:25)

fix: tune vsock dial for buildkite hosts
Signed-off-by: Austin Vazquez <macedonv@amazon.com>

*Issue #, if available:*
#673 

*Description of changes:*
Tune vsock dial based on Buildkite host performance. Should be made more robust by #689 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml
index af6535a..0633860 100644
--- a/.buildkite/pipeline.yml
+++ b/.buildkite/pipeline.yml
@@ -88,10 +88,6 @@ steps:
     command:
       - make -C runtime integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_runtime
 
-  - wait
-
-  # Let's isolate the remote snapshotter integration tests.
-  # See https://github.com/firecracker-microvm/firecracker-containerd/issues/673
   - label: ":running: snapshotter isolated tests"
     agents:
       queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
@@ -108,8 +104,6 @@ steps:
       - make -C snapshotter integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_snapshotter
     timeout_in_minutes: 10
 
-  - wait
-
   - label: ":weight_lifter: stress tests"
     concurrency_group: stress
     concurrency: 1
diff --git a/snapshotter/app/service.go b/snapshotter/app/service.go
index cc7e9e8..840750a 100644
--- a/snapshotter/app/service.go
+++ b/snapshotter/app/service.go
@@ -177,9 +177,12 @@ func initSnapshotter(ctx context.Context, config config.Config, cache cache.Cach
 			return nil, err
 		}
 
-		ackMsgTimeout := time.Duration(config.Snapshotter.Dialer.AckMsgTimeoutInSeconds) * time.Second
+		// TODO: https://github.com/firecracker-microvm/firecracker-containerd/issues/689
 		snapshotterDialer := func(ctx context.Context, namespace string) (net.Conn, error) {
-			return vsock.DialContext(ctx, host, uint32(port), vsock.WithLogger(log.G(ctx)), vsock.WithAckMsgTimeout(ackMsgTimeout))
+			return vsock.DialContext(ctx, host, uint32(port), vsock.WithLogger(log.G(ctx)),
+				vsock.WithAckMsgTimeout(2*time.Second),
+				vsock.WithRetryInterval(200*time.Millisecond),
+			)
 		}
 
 		var metricsProxy *metrics.Proxy
diff --git a/snapshotter/config/config.go b/snapshotter/config/config.go
index b4e01de..3b42b0f 100644
--- a/snapshotter/config/config.go
+++ b/snapshotter/config/config.go
@@ -32,7 +32,6 @@ type Config struct {
 
 type snapshotter struct {
 	Listener listener `toml:"listener"`
-	Dialer   dialer   `toml:"dialer"`
 	Proxy    proxy    `toml:"proxy"`
 	Metrics  metrics  `toml:"metrics"`
 }
@@ -42,10 +41,6 @@ type listener struct {
 	Address string `toml:"address" default:"/var/lib/demux-snapshotter/snapshotter.sock"`
 }
 
-type dialer struct {
-	AckMsgTimeoutInSeconds int `toml:"ack_msg_timeout_in_seconds" default:"1"`
-}
-
 type proxy struct {
 	Address address `toml:"address"`
 }
diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh
index 486e642..f8e225c 100755
--- a/tools/docker/entrypoint.sh
+++ b/tools/docker/entrypoint.sh
@@ -42,9 +42,6 @@ EOF
 
 mkdir -p /etc/demux-snapshotter /var/lib/demux-snapshotter
 cat > /etc/demux-snapshotter/config.toml <<EOF
-[snapshotter.dialer]
-  ack_msg_timeout_in_seconds = 2
-
 [snapshotter.proxy.address.resolver]
   type = "http"
   address = "http://127.0.0.1:10001"


Test patch:
diff --git a/snapshotter/config/config_test.go b/snapshotter/config/config_test.go
index 2f7c581..911a4a5 100644
--- a/snapshotter/config/config_test.go
+++ b/snapshotter/config/config_test.go
@@ -62,9 +62,6 @@ func defaultConfig() error {
 				Network: "unix",
 				Address: "/var/lib/demux-snapshotter/snapshotter.sock",
 			},
-			Dialer: dialer{
-				AckMsgTimeoutInSeconds: 1,
-			},
 			Metrics: metrics{
 				Enable: false,
 			},
@@ -82,8 +79,6 @@ func parseExampleConfig() error {
 	  [snapshotter.listener]
 	    network = "unix"
 	    address = "/var/lib/demux-snapshotter/non-default-snapshotter.vsock"
-	  [snapshotter.dialer]
-	    ack_msg_timeout_in_seconds = 4
 	  [snapshotter.proxy.address.resolver]
 	    type = "http"
 	    address = "localhost:10001"
@@ -101,9 +96,6 @@ func parseExampleConfig() error {
 				Network: "unix",
 				Address: "/var/lib/demux-snapshotter/non-default-snapshotter.vsock",
 			},
-			Dialer: dialer{
-				AckMsgTimeoutInSeconds: 4,
-			},
 			Proxy: proxy{
 				Address: address{
 					Resolver: resolver{