-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
func: fix the last_log_index check and add a versions check
- Loading branch information
1 parent
3d6de7f
commit d29e3d9
Showing
4 changed files
with
100 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters