Keep module rebuild sentinel in sync across local and shared storage

This commit is contained in:
uprightbass360
2025-10-25 19:50:59 -04:00
parent ab7b982d9b
commit 731413f4ae
3 changed files with 46 additions and 14 deletions

View File

@@ -822,14 +822,24 @@ if [ "$MODULES_LOCAL_RUN" = "1" ]; then
else else
REBUILD_SENTINEL="/modules/.requires_rebuild" REBUILD_SENTINEL="/modules/.requires_rebuild"
fi fi
HOST_REBUILD_SENTINEL="${MODULES_HOST_DIR:-}"
if [ -n "$HOST_REBUILD_SENTINEL" ]; then
HOST_REBUILD_SENTINEL="${HOST_REBUILD_SENTINEL%/}/.requires_rebuild"
fi
if [ "$SQL_EXECUTION_FAILED" = "1" ]; then if [ "$SQL_EXECUTION_FAILED" = "1" ]; then
echo "⚠️ SQL execution encountered issues; review logs above." echo "⚠️ SQL execution encountered issues; review logs above."
fi fi
if [ "$REBUILD_REQUIRED" = "1" ] && [ -n "$ENABLED_MODULES" ]; then if [ "$REBUILD_REQUIRED" = "1" ] && [ -n "$ENABLED_MODULES" ]; then
echo "$ENABLED_MODULES" > "$REBUILD_SENTINEL" echo "$ENABLED_MODULES" > "$REBUILD_SENTINEL"
if [ -n "$HOST_REBUILD_SENTINEL" ]; then
echo "$ENABLED_MODULES" > "$HOST_REBUILD_SENTINEL" 2>/dev/null || true
fi
else else
rm -f "$REBUILD_SENTINEL" 2>/dev/null || true rm -f "$REBUILD_SENTINEL" 2>/dev/null || true
if [ -n "$HOST_REBUILD_SENTINEL" ]; then
rm -f "$HOST_REBUILD_SENTINEL" 2>/dev/null || true
fi
fi fi
# Optional: keep container alive for inspection in CI/debug contexts # Optional: keep container alive for inspection in CI/debug contexts

View File

@@ -314,23 +314,35 @@ docker compose down --remove-orphans >/dev/null 2>&1 || true
popd >/dev/null popd >/dev/null
if [ -n "$SENTINEL_FILE" ]; then remove_sentinel(){
if ! rm -f "$SENTINEL_FILE" 2>/dev/null; then local sentinel_path="$1"
if [ -f "$SENTINEL_FILE" ] && command -v docker >/dev/null 2>&1; then [ -n "$sentinel_path" ] || return 0
DB_IMPORT_IMAGE="$(read_env AC_DB_IMPORT_IMAGE "acore/ac-wotlk-db-import:14.0.0-dev")" [ -f "$sentinel_path" ] || return 0
if docker image inspect "$DB_IMPORT_IMAGE" >/dev/null 2>&1; then if rm -f "$sentinel_path" 2>/dev/null; then
docker run --rm \ return 0
--entrypoint /bin/sh \ fi
--user 0:0 \ if command -v docker >/dev/null 2>&1; then
-v "$MODULES_DIR":/modules \ local db_image
"$DB_IMPORT_IMAGE" \ db_image="$(read_env AC_DB_IMPORT_IMAGE "acore/ac-wotlk-db-import:14.0.0-dev")"
-c 'rm -f /modules/.requires_rebuild' >/dev/null 2>&1 || true if docker image inspect "$db_image" >/dev/null 2>&1; then
fi local mount_dir
mount_dir="$(dirname "$sentinel_path")"
docker run --rm \
--entrypoint /bin/sh \
--user 0:0 \
-v "$mount_dir":/modules \
"$db_image" \
-c 'rm -f /modules/.requires_rebuild' >/dev/null 2>&1 || true
fi fi
fi fi
if [ -f "$SENTINEL_FILE" ]; then if [ -f "$sentinel_path" ]; then
echo "⚠️ Unable to remove rebuild sentinel at $SENTINEL_FILE. Remove manually if rebuild detection persists." echo "⚠️ Unable to remove rebuild sentinel at $sentinel_path. Remove manually if rebuild detection persists."
fi fi
}
remove_sentinel "$SENTINEL_FILE"
if [ -n "$SHARED_MODULES_DIR" ]; then
remove_sentinel "$SHARED_MODULES_DIR/.requires_rebuild"
fi fi
echo "" echo ""

View File

@@ -1146,6 +1146,9 @@ fi
export "$module_export_var" export "$module_export_var"
done done
local host_modules_dir="${storage_abs}/modules"
export MODULES_HOST_DIR="$host_modules_dir"
# Prepare isolated git config for the module script so we do not mutate user-level settings # Prepare isolated git config for the module script so we do not mutate user-level settings
local prev_git_config_global="${GIT_CONFIG_GLOBAL:-}" local prev_git_config_global="${GIT_CONFIG_GLOBAL:-}"
local git_temp_config="" local git_temp_config=""
@@ -1165,10 +1168,17 @@ fi
export MODULES_LOCAL_RUN=1 export MODULES_LOCAL_RUN=1
if (cd "$local_modules_dir" && bash "$SCRIPT_DIR/scripts/manage-modules.sh"); then if (cd "$local_modules_dir" && bash "$SCRIPT_DIR/scripts/manage-modules.sh"); then
say SUCCESS "Module repositories staged to $local_modules_dir" say SUCCESS "Module repositories staged to $local_modules_dir"
if [ -n "$host_modules_dir" ]; then
mkdir -p "$host_modules_dir"
if [ -f "$local_modules_dir/.modules_state" ]; then
cp "$local_modules_dir/.modules_state" "$host_modules_dir/.modules_state" 2>/dev/null || true
fi
fi
else else
say WARNING "Module staging encountered issues, but continuing with rebuild" say WARNING "Module staging encountered issues, but continuing with rebuild"
fi fi
unset MODULES_LOCAL_RUN unset MODULES_LOCAL_RUN
unset MODULES_HOST_DIR
if [ -n "$git_temp_config" ]; then if [ -n "$git_temp_config" ]; then
rm -f "$git_temp_config" rm -f "$git_temp_config"