From 47a83449451130c77807e182c21d486e2ab9f83d Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 9 Mar 2023 10:40:08 +0100 Subject: [PATCH] Actually fix the CI workflow (#79) --- .github/workflows/ci.yml | 10 +++------- Makefile | 1 + hack/collect_logs.sh | 17 +++++++++++++++++ hack/local_ironic.sh | 28 ++++++++++++++++++++++++---- 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100755 hack/collect_logs.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8a26e9c0..7a331f044 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: go-version: 1.19 - name: Install dependencies - run: sudo apt-get install -y genisoimage docker netcat + run: sudo apt-get install -y genisoimage podman netcat - name: Start Ironic and Inspector run: ./hack/local_ironic.sh @@ -41,10 +41,6 @@ jobs: - name: Run tests run: make acceptance - - name: Collect Ironic logs + - name: Collect logs if: always() - run: docker logs ironic - - - name: Collect Inspector logs - if: always() - run: docker logs inspector + run: ./hack/collect_logs.sh diff --git a/Makefile b/Makefile index 38a599507..3ccbf5c9b 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ LDFLAGS += -X main.version=$$(git describe --always --abbrev=40 --dirty) TEST?=$$(go list ./... |grep -v 'vendor') PKG_NAME=ironic TERRAFORM_PLUGINS=$(HOME)/.terraform.d/plugins +GOPATH?=$$(go env GOPATH) ifeq ("$(IRONIC_ENDPOINT)", "") IRONIC_ENDPOINT := http://127.0.0.1:6385/ diff --git a/hack/collect_logs.sh b/hack/collect_logs.sh new file mode 100755 index 000000000..8229c54df --- /dev/null +++ b/hack/collect_logs.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -xe + +if $(which podman > /dev/null 2>&1); then + CONTAINER_RUNTIME=podman +else + CONTAINER_RUNTIME=docker +fi + +set +x + +echo "******************** IRONIC LOGS ********************" +sudo $CONTAINER_RUNTIME logs ironic || true +echo +echo "******************* INSPECTOR LOGS ******************" +sudo $CONTAINER_RUNTIME logs ironic-inspector || true diff --git a/hack/local_ironic.sh b/hack/local_ironic.sh index fedac13b2..ca8eafd09 100755 --- a/hack/local_ironic.sh +++ b/hack/local_ironic.sh @@ -8,11 +8,31 @@ else CONTAINER_RUNTIME=docker fi +IMAGE=${IMAGE:-quay.io/metal3-io/ironic:main} + sudo $CONTAINER_RUNTIME run -d --net host --privileged --name ironic \ - --entrypoint /bin/runironic -e "PROVISIONING_IP=127.0.0.1" quay.io/metal3-io/ironic:master + --entrypoint /bin/runironic -e "PROVISIONING_IP=127.0.0.1" $IMAGE sudo $CONTAINER_RUNTIME run -d --net host --privileged --name ironic-inspector \ - -e "PROVISIONING_IP=127.0.0.1" quay.io/metal3-io/ironic-inspector:master + --entrypoint /bin/runironic-inspector -e "PROVISIONING_IP=127.0.0.1" $IMAGE + +for attempt in {1..30}; do + sleep 2 + + if ! curl -I http://127.0.0.1:6385; then + if [[ $attempt == 30 ]]; then + exit 1 + else + continue + fi + fi + + if ! curl -I http://127.0.0.1:5050; then + if [[ $attempt == 30 ]]; then + exit 1 + else + continue + fi + fi -for p in 6385 5050; do - nc -z -w 60 127.0.0.1 ${p} + break done