mirror of
https://github.com/kemko/nomad.git
synced 2026-01-10 12:25:42 +03:00
* func: add dependencies to avoid race conditions and move the update to each client to the main upgrade scenario * Update enos/enos-scenario-upgrade.hcl Co-authored-by: Tim Gross <tgross@hashicorp.com> * Update enos/enos-scenario-upgrade.hcl Co-authored-by: Tim Gross <tgross@hashicorp.com> --------- Co-authored-by: Tim Gross <tgross@hashicorp.com>
52 lines
1.6 KiB
Bash
Executable File
52 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
set -euo pipefail
|
|
|
|
error_exit() {
|
|
printf 'Error: %s' "${1}"
|
|
exit 1
|
|
}
|
|
|
|
# Servers version
|
|
server_versions=$(nomad server members -json | jq -r '[.[] | select(.Status == "alive") | .Tags.build] | unique')
|
|
|
|
if [ "$(echo "$server_versions" | jq 'length')" -eq 0 ]; then
|
|
error_exit "Unable to get servers version"
|
|
fi
|
|
|
|
if [ "$(echo "$server_versions" | jq 'length')" -ne 1 ]; then
|
|
error_exit "Servers are running different versions: $(echo "$server_versions" | jq -c '.')"
|
|
fi
|
|
|
|
final_version=$(echo "$server_versions" | jq -r '.[0]'| xargs)
|
|
SERVERS_VERSION=$(echo "$SERVERS_VERSION" | xargs)
|
|
|
|
if [ "$final_version" != "$SERVERS_VERSION" ]; then
|
|
error_exit "Servers are not running the correct version. Found: $final_version, Expected: $SERVERS_VERSION"
|
|
fi
|
|
|
|
echo "All servers are running Nomad version $SERVERS_VERSION"
|
|
|
|
# Clients version
|
|
clients_versions=$(nomad node status -json | jq -r '[.[] | select(.Status == "ready") | .Version] | unique')
|
|
|
|
if [ "$(echo "$clients_versions" | jq 'length')" -eq 0 ]; then
|
|
error_exit "Unable to get clients version"
|
|
fi
|
|
|
|
|
|
if [ "$(echo "$clients_versions" | jq 'length')" -ne 1 ]; then
|
|
error_exit "Clients are running different versions: $(echo "$clients_versions" | jq -c '.')"
|
|
fi
|
|
|
|
final_version=$(echo "$clients_versions" | jq -r '.[0]'| xargs)
|
|
CLIENTS_VERSION=$(echo "$CLIENTS_VERSION" | xargs)
|
|
|
|
if [ "$final_version" != "$CLIENTS_VERSION" ]; then
|
|
error_exit "Clients are not running the correct version. Found: $final_version, Expected: $CLIENTS_VERSION"
|
|
fi
|
|
|
|
echo "All clients are running Nomad version $CLIENTS_VERSION"
|