Skip to content

Commit 10a2905

Browse files
committed
readability updates
1 parent 659b807 commit 10a2905

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

bin/ghe-host-check

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,36 +120,32 @@ fi
120120
NON_WRITABLE=""
121121
# ensure all nodes are writable
122122
if [ "$CLUSTER" == "true" ] ; then
123-
if [ -z "$GHE_FILE_SYSTEM_CHECK" ]; then
123+
if [ -z "$GHE_FILE_SYSTEM_WRITE_CHECK" ]; then
124124
if [ -d "/data/user/tmp" ]; then
125-
FILE_TO_TEST="/data/user/tmp/test-ro-file.txt"
125+
WRITE_CHECK_FILE="/data/user/tmp/test-ro-file.txt"
126126
else
127-
FILE_TO_TEST="/tmp/test-ro-file.txt"
127+
WRITE_CHECK_FILE="/tmp/test-ro-file.txt"
128128
fi
129129
else
130-
FILE_TO_TEST="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt"
130+
WRITE_CHECK_FILE="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt"
131131
fi
132132

133133
# Iterate through each node in the cluster
134134
nodes=$(ghe-ssh "$host" ghe-cluster-nodes)
135135
first=true
136136
for node in $nodes; do
137-
if ! echo "set -o pipefail; ssh $node -- 'touch $FILE_TO_TEST && rm $FILE_TO_TEST'" | ghe-ssh "$host" /bin/bash; then
137+
if ! echo "set -o pipefail; ssh $node -- 'touch $WRITE_CHECK_FILE && rm $WRITE_CHECK_FILE'" | ghe-ssh "$host" /bin/bash; then
138138
echo "File system is not writeable or no permission on $node" 1>&2
139-
if [ "$first" = true ]; then
140-
NON_WRITABLE="$node"
141-
first=false
142-
else
143-
NON_WRITABLE="$NON_WRITABLE, $node"
144-
fi
139+
NON_WRITABLE+="$node "
145140
fi || true
146141
done
147142
# Display the comma-separated list of non-writable nodes
148-
if [ ! -z "$NON_WRITABLE" ]; then
143+
if [ -n "$NON_WRITABLE" ]; then
144+
NON_WRITABLE=$(echo "$NON_WRITABLE" | sed 's/ /, /g; s/, $//')
149145
log_error "Error: Following nodes are non-writable - $NON_WRITABLE. Please make sure the filesystem for all GHES nodes are writable." 1>&2
150146
exit 1
151147
else
152-
echo "All nodes are writable."
148+
log_info "All nodes are writable."
153149
fi
154150
fi
155151

test/test-ghe-host-check.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ begin_test "ghe-host-check fails when encountering RO file-system"
134134
ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"'
135135

136136
# File creation fails for CLUSTER
137-
! FILE_TO_TEST="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check
138-
FILE_TO_TEST="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check
137+
! WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check
138+
WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check
139139
)
140140
end_test

0 commit comments

Comments
 (0)