diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be1d5c1..33381e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -153,7 +153,7 @@ test_e2e: - nomad validate deploy/api.nomad # nomad plan returns 1 if allocation is created or destroyed which is what we want here - nomad plan deploy/api.nomad || [ $? == 1 ] - - nomad-run-and-wait deploy/api.nomad + - nomad run deploy/api.nomad artifacts: paths: - deploy/api.nomad diff --git a/deploy/nomad-ci/Dockerfile b/deploy/nomad-ci/Dockerfile index 621c5ff..543ce77 100644 --- a/deploy/nomad-ci/Dockerfile +++ b/deploy/nomad-ci/Dockerfile @@ -24,14 +24,13 @@ RUN apt-get update && \ apt-get install -y docker-ce docker-ce-cli containerd.io && \ rm -rf /var/lib/apt/lists +ENV NOMAD_VERSION="1.1.2" + # Download Nomad -RUN wget "https://releases.hashicorp.com/nomad/1.1.1/nomad_1.1.1_linux_amd64.zip" && \ - wget "https://releases.hashicorp.com/nomad/1.1.1/nomad_1.1.1_SHA256SUMS" && \ - grep "nomad_1.1.1_linux_amd64.zip" nomad_1.1.1_SHA256SUMS | sha256sum -c - && \ - unzip nomad_1.1.1_linux_amd64.zip +RUN wget "https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip" && \ + wget "https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS" && \ + grep "nomad_${NOMAD_VERSION}_linux_amd64.zip" nomad_${NOMAD_VERSION}_SHA256SUMS | sha256sum -c - && \ + unzip nomad_${NOMAD_VERSION}_linux_amd64.zip # Install Nomad RUN mv nomad /usr/sbin/ && nomad -version - -COPY nomad-run-and-wait /usr/sbin/ -RUN chmod +x /usr/sbin/nomad-run-and-wait diff --git a/deploy/nomad-ci/nomad-run-and-wait b/deploy/nomad-ci/nomad-run-and-wait deleted file mode 100644 index 80ba679..0000000 --- a/deploy/nomad-ci/nomad-run-and-wait +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# Script that runs a Nomad job and watches the deployment status until it finished running -# See https://github.com/hashicorp/nomad/issues/6818 - -if [[ $# -eq 0 ]]; then - echo "Usage: $0 " - exit 1 -fi - -output=$(nomad run $1 2>&1) - -if [[ $? -ne 0 ]]; then - echo $output - exit 1 -fi - -deployment=$(grep -oP "(?<=Evaluation within deployment: \").*(?=\")" <<<$output) - -echo "Monitoring deployment $deployment" - -timeout=300 -sleepDuration=4 -iterations=$((timeout / sleepDuration)) - -for i in $(seq $iterations); do - if [[ $i -eq $iterations ]]; then - # timeout reached, fail deployment and exit - nomad deployment fail $deployment - exit 1 - fi - output=$(nomad deployment status $deployment 2>&1) - grep -E "Status" <<<$output - running=$(grep -E "Status.*=.*running" <<<$output) - if [[ -z "$running" ]]; then - break - fi - sleep $sleepDuration -done - -echo "#######" -echo "$output" -failed=$(grep -E "Status.*=.*failed" <<<$output) -if [[ -n "$failed" ]]; then - exit 1 -fi - -exit 0