From aaad60dec7cbea13b07e0a5ecf872a29f77662cc Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Wed, 28 Sep 2022 17:45:31 -0400 Subject: [PATCH] ci(deploy): retry ssh connections if it fails (#5292) Previous behavior From time to time SSH connections to deployed VMs fails with the following error: `kex_exchange_identification: Connection closed by remote host` Expected behavior If the connection fails, attempt to reconnect once again (or multiple times) Solution Add the `ConnectionAttempts` and `ConnectTimeout` with 20 and 5 values respectively, which attempst to reconnect 19 more times every 5 seconds --- .github/workflows/deploy-gcp-tests.yml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/deploy-gcp-tests.yml b/.github/workflows/deploy-gcp-tests.yml index 34e505fe7..7f524169e 100644 --- a/.github/workflows/deploy-gcp-tests.yml +++ b/.github/workflows/deploy-gcp-tests.yml @@ -161,6 +161,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ sudo mkfs.ext4 -v /dev/sdb \ @@ -213,6 +215,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker run \ @@ -381,6 +385,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ sudo e2fsck -v -f -p /dev/sdb \ @@ -455,6 +461,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker run \ @@ -503,6 +511,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker run \ @@ -568,6 +578,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -628,6 +640,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -685,6 +699,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -744,6 +760,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -805,6 +823,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -866,6 +886,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -928,6 +950,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -988,6 +1012,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -1044,6 +1070,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command \ "\ docker logs \ @@ -1111,6 +1139,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command=' \ set -e; docker logs \ @@ -1232,6 +1262,8 @@ jobs: --zone ${{ env.ZONE }} \ --quiet \ --ssh-flag="-o ServerAliveInterval=5" \ + --ssh-flag="-o ConnectionAttempts=20" \ + --ssh-flag="-o ConnectTimeout=5" \ --command=" \ docker logs ${{ inputs.test_id }} --tail 200 \ ")