Skip to content

Commit c30b464

Browse files
committed
check for RO file-system
1 parent 0007359 commit c30b464

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

bin/ghe-host-check

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,39 @@ if [ -z "$version" ]; then
115115
exit 2
116116
fi
117117

118+
NON_WRITABLE=""
119+
# ensure all nodes are writable
120+
if "$CLUSTER"; then
121+
if [ -z "$FILE_TO_TEST" ]; then
122+
FILE_TO_TEST="/data/user/tmp/test-ro-file.txt"
123+
fi
124+
125+
# Iterate through each node in the cluster
126+
nodes=$(ghe-ssh "$host" ghe-cluster-nodes)
127+
first=true
128+
# echo $nodes | while read -r node; do
129+
for node in $nodes; do
130+
if ! $(echo "set -o pipefail; ssh "$node" -- 'touch "$FILE_TO_TEST" && rm "$FILE_TO_TEST"'" | ghe-ssh "$host" /bin/bash); then
131+
#echo "File system is writable on $node"
132+
#else
133+
echo "File system is not writeable on $node" 1>&2
134+
if [ "$first" = true ]; then
135+
NON_WRITABLE="$node"
136+
first=false
137+
else
138+
NON_WRITABLE="$NON_WRITABLE, $node"
139+
fi
140+
fi || true
141+
done
142+
# Display the comma-separated list of non-writable nodes
143+
if [ ! -z "$NON_WRITABLE" ]; then
144+
echo "Error: Non-writable nodes: $NON_WRITABLE . Please make sure the file systems for all Enterprise nodes are writable." 1>&2
145+
exit 1
146+
else
147+
echo "All nodes are writable."
148+
fi
149+
fi
150+
118151
# Block restoring snapshots to older releases of GitHub Enterprise Server
119152
if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then
120153
snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
@@ -177,7 +210,7 @@ SKIP_MSG
177210

178211
#Display dir requirements for repositories and mysql
179212
echo -e "\nChecking host for sufficient space for a backup..."
180-
available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}')
213+
available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}')
181214
echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time."
182215

183216
repos_disk_size=$(transfer_size repositories /tmp)

test/test-ghe-host-check.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,13 @@ begin_test "ghe-host-check blocks restore to old release"
123123
! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v
124124
)
125125
end_test
126+
127+
# Check ghe-host-check detects RO file system
128+
begin_test "ghe-host-check fails when encountering RO file-system"
129+
(
130+
set -e
131+
132+
enable_ro_fs
133+
! FILE_TO_TEST=/run/user/501/test ghe-host-check
134+
)
135+
end_test

test/testlib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,7 @@ setup_actions_enabled_settings_for_restore() {
728728
echo > "$GHE_DATA_DIR/1/settings.json"
729729
git config -f "$GHE_DATA_DIR/1/settings.json" --bool app.actions.enabled $1
730730
}
731+
732+
enable_ro_fs() {
733+
ghe-ssh "$GHE_HOSTNAME" -- 'sudo mount -o remount,rw /run/user/501'
734+
}

0 commit comments

Comments
 (0)