Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #90 from dhiltgen/more_tests
Browse files Browse the repository at this point in the history
Unmask error in retry loop and add time
  • Loading branch information
dhiltgen authored May 18, 2021
2 parents 618bd50 + 5f9c4d6 commit 2abb51e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
test-unit:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
Expand All @@ -31,7 +31,7 @@ jobs:
name: codecov-unit-test

test-integration-containerd:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
Expand All @@ -44,7 +44,10 @@ jobs:
- name: Setup containerd cluster
run: |
set -x
sudo apt-get install -y kubeadm kubelet
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo swapoff -a
# Ensure dockerd isn't running
sudo systemctl stop docker.socket
Expand All @@ -68,7 +71,7 @@ jobs:
name: codecov-integration-test-containerd

test-integration-dockerd:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
Expand All @@ -81,7 +84,10 @@ jobs:
- name: Setup kubeadm cluster with default docker runtime
run: |
set -x
sudo apt-get install -y kubeadm kubelet
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo swapoff -a
sudo kubeadm init
mkdir -p $HOME/.kube/
Expand All @@ -103,7 +109,7 @@ jobs:
name: codecov-integration-test-dockerd

lint:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
Expand All @@ -117,7 +123,7 @@ jobs:
version: v1.29

build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
RAW_VERSION: ${{ steps.get_version.outputs.RAW_VERSION }}
Expand Down
6 changes: 4 additions & 2 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package driver
import (
"context"
"io"
"math/rand"
"net"
"strings"
"time"
Expand Down Expand Up @@ -95,6 +96,7 @@ type Node struct {

func Boot(ctx context.Context, d Driver, pw progress.Writer) (*client.Client, string, error) {
try := 0
rand.Seed(time.Now().UnixNano())
for {
info, err := d.Info(ctx)
if err != nil {
Expand All @@ -105,14 +107,14 @@ func Boot(ctx context.Context, d Driver, pw progress.Writer) (*client.Client, st
if try > maxBootRetries {
return nil, "", errors.Errorf("failed to bootstrap builder in %d attempts (%s)", try, err)
}
if err := d.Bootstrap(ctx, func(s *client.SolveStatus) {
if err = d.Bootstrap(ctx, func(s *client.SolveStatus) {
if pw != nil {
pw.Status() <- s
}
}); err != nil && (strings.Contains(err.Error(), "already exists") || strings.Contains(err.Error(), "not found")) {
// This most likely means another build is running in parallel
// Give it just enough time to finish creating resources then retry
time.Sleep(250 * time.Millisecond)
time.Sleep(25 * time.Millisecond * time.Duration(1+rand.Int63n(39))) // 25 - 1000 ms
continue
} else if err != nil {
return nil, "", err
Expand Down

0 comments on commit 2abb51e

Please sign in to comment.