Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pipeline/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
helm version --short
kubectl version --client
yq --version
go mod download
sh ./hack/retry-go.sh mod download
df -h /
mkdir -p "$LOG_DIR"
displayName: Check E2E prerequisites
Expand Down
4 changes: 3 additions & 1 deletion docker/hub-gateway-controller-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ ARG GOARCH=amd64
WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
RUN --mount=type=cache,target=/go/pkg/mod go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=hack/retry-go.sh,target=/tmp/retry-go.sh \
sh /tmp/retry-go.sh mod download

COPY cmd/hub-gateway-controller-manager/ cmd/hub-gateway-controller-manager/
COPY api/ api/
Expand Down
4 changes: 3 additions & 1 deletion docker/hub-net-controller-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ COPY go.mod go.mod
COPY go.sum go.sum
# Cache the downloaded dependency modules across different builds to expedite the progress.
# This also helps reduce downloading related reliability issues in our build environment.
RUN --mount=type=cache,target=/go/pkg/mod go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=hack/retry-go.sh,target=/tmp/retry-go.sh \
sh /tmp/retry-go.sh mod download

# Copy the go source
COPY cmd/hub-net-controller-manager/main.go main.go
Expand Down
4 changes: 3 additions & 1 deletion docker/mcs-controller-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ COPY go.mod go.mod
COPY go.sum go.sum
# Cache the downloaded dependency modules across different builds to expedite the progress.
# This also helps reduce downloading related reliability issues in our build environment.
RUN --mount=type=cache,target=/go/pkg/mod go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=hack/retry-go.sh,target=/tmp/retry-go.sh \
sh /tmp/retry-go.sh mod download

# Copy the go source
COPY cmd/mcs-controller-manager/main.go main.go
Expand Down
4 changes: 3 additions & 1 deletion docker/member-net-controller-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ COPY go.mod go.mod
COPY go.sum go.sum
# Cache the downloaded dependency modules across different builds to expedite the progress.
# This also helps reduce downloading related reliability issues in our build environment.
RUN --mount=type=cache,target=/go/pkg/mod go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=hack/retry-go.sh,target=/tmp/retry-go.sh \
sh /tmp/retry-go.sh mod download

# Copy the go source
COPY cmd/member-net-controller-manager/main.go main.go
Expand Down
4 changes: 3 additions & 1 deletion docker/net-crd-installer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ COPY go.mod go.mod
COPY go.sum go.sum
# Cache the downloaded dependency modules across different builds to expedite the progress.
# This also helps reduce downloading related reliability issues in our build environment.
RUN --mount=type=cache,target=/go/pkg/mod go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=hack/retry-go.sh,target=/tmp/retry-go.sh \
sh /tmp/retry-go.sh mod download

# Copy the go source
COPY cmd/net-crd-installer/ cmd/net-crd-installer/
Expand Down
3 changes: 2 additions & 1 deletion hack/go-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if [[ -z "${GOBIN}" ]]; then
exit 1
fi

retry_go="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/retry-go.sh"
tmp_dir=$(mktemp -d -t goinstall_XXXXXXXXXX)
function clean {
rm -rf "${tmp_dir}"
Expand All @@ -39,6 +40,6 @@ cd "${tmp_dir}"
go mod init fake/mod

# install the golang module specified as the first argument
go install "${1}@${3}"
sh "$retry_go" install "${1}@${3}"
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"
20 changes: 20 additions & 0 deletions hack/retry-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu

if [ "$#" -eq 0 ]; then
echo "error: provide a Go command to retry" >&2
exit 1
fi

for attempt in 1 2 3; do
if go "$@"; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "error: go $* failed after 3 attempts" >&2
exit 1
fi
delay=$((attempt * 10))
echo "go $* failed; retrying in $delay seconds..." >&2
sleep "$delay"
done
Loading