Skip to content

Commit

Permalink
[Backport release/1.5] CASMPET-7263: Force goss-servers to wait until…
Browse files Browse the repository at this point in the history
… hostname is set (#612)

* CASMPET-7263: Force goss-servers to wait until hostname is set

(cherry picked from commit ce58e96)

* Wait for csm-testing RPM to be installed before starting goss-servers

(cherry picked from commit 651b008)

---------

Co-authored-by: Mitch Harding (the weird one) <mitchell.harding@hpe.com>
  • Loading branch information
github-actions[bot] and mharding-hpe authored Oct 28, 2024
1 parent 17d9b4f commit f231cb3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions systemd/start-goss-servers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ fi
export KUBECONFIG=/etc/kubernetes/admin.conf

# necessary for test that need to know the current hostname
# It is possible for this service to start before cloud-init has assigned a hostname to the NCN.
# If the hostname is not in one of the expected formats, sleep and check later.
pattern="(ncn-[msw][0-9]{3}|-pit)$"
HOSTNAME=$(hostname -s)
while [[ ! ${HOSTNAME} =~ ${pattern} ]]; do
sleep 5
HOSTNAME=$(hostname -s)
done

export HOSTNAME

# During the NCN image build, this service is started, even though the csm-testing RPM is not installed. In that
Expand All @@ -44,6 +52,12 @@ export HOSTNAME
# there is likewise a chance that this service is started just before the csm-testing RPM has been installed. In both
# cases, the solution if the run-ncn-tests.sh file does not exist (or exists but is empty, for some weird reason)
# is to sleep for a bit and check again.
while ! rpm -q csm-testing > /dev/null 2>&1; do
sleep 5
done
# Include the versions of these to help with debugging
rpm -q csm-testing goss-servers

while [[ ! -s "${GOSS_BASE}/automated/run-ncn-tests.sh" ]]; do
sleep 5
done
Expand Down

0 comments on commit f231cb3

Please sign in to comment.