Skip to content

Commit 454df29

Browse files
Milan Majchrákclaude
andcommitted
ci(deploy): split probe into its own job + PROBE_ONLY; fix dump path
First run on dev-6 (29501166150) proved two assumptions wrong: - the dump is NOT at /opt/dspace-envs/8603/<file>.sql; that dir holds a dump/ subdir, so DUMP_PATH now defaults to 8603/dump/dspace_dev5_dump_26.07.16.sql (jcu's convention after all) - postgres inside dspacedb8603 listens on the DEFAULT 5432, so copying jcu (no -p flag) is right; mendelu's -p 10573 is instance-specific The deploy then failed with 'Bind for 0.0.0.0:5432 failed: port is already allocated', so make the probe a standalone job with PROBE_ONLY, to diagnose port ownership without deploying anything. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 61e1ee5 commit 454df29

1 file changed

Lines changed: 56 additions & 15 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,75 @@ on:
4949
description: 'Absolute path of the SQL dump ON THE DEV MACHINE (used only when IMPORT is checked)'
5050
required: false
5151
type: string
52-
default: '/opt/dspace-envs/8603/dspace_dev5_dump_26.07.16.sql'
52+
default: '/opt/dspace-envs/8603/dump/dspace_dev5_dump_26.07.16.sql'
53+
PROBE_ONLY:
54+
description: 'Only report the state of the target machine; deploy and import nothing'
55+
required: false
56+
default: false
57+
type: boolean
5358

5459
jobs:
55-
deploy-8603:
56-
if: inputs.INSTANCE == '*' || inputs.INSTANCE == '8603'
60+
# Read-only report of the machine we are about to touch. Runs first so that a
61+
# misconfigured target is visible in the log even when the deploy then fails.
62+
probe:
5763
runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1
58-
timeout-minutes: 60
64+
timeout-minutes: 10
5965
env:
60-
INSTANCE: '8603'
66+
INSTANCE: ${{inputs.INSTANCE}}
6167
CONFIG_PATH: /opt/dspace-envs/${{inputs.INSTANCE}}
6268
ENVFILE: /opt/dspace-envs/${{inputs.INSTANCE}}/.env
6369
steps:
6470
- uses: actions/checkout@v6
6571

66-
# Report the environment we are about to deploy into. Everything here is
67-
# tolerant of failure: it must never be the reason a deploy goes red.
68-
- name: probe environment
72+
- name: config dir + dump
6973
run: |
7074
echo "===== $CONFIG_PATH"
7175
ls -la "$CONFIG_PATH/" || echo "MISSING: $CONFIG_PATH"
72-
echo "===== .env keys (values redacted)"
73-
sed 's/=.*/=<redacted>/' "$ENVFILE" || echo "MISSING: $ENVFILE"
74-
echo "===== containers for instance $INSTANCE"
75-
docker ps -a --format '{{.Names}}\t{{.Image}}\t{{.Status}}' | grep -E "${INSTANCE}" || echo "no containers matching $INSTANCE"
76-
echo "===== postgres port inside dspacedb$INSTANCE"
77-
docker exec dspacedb$INSTANCE sh -c 'echo "PGPORT=$PGPORT"; pg_isready -U dspace; psql -U dspace -d postgres -tAc "SHOW port;" 2>/dev/null' || echo "could not probe dspacedb$INSTANCE"
78-
echo "===== dump file"
76+
echo "===== $CONFIG_PATH/dump"
77+
ls -la "$CONFIG_PATH/dump/" || echo "MISSING: $CONFIG_PATH/dump"
78+
echo "===== dump referenced by DUMP_PATH input"
7979
ls -la "${{ inputs.DUMP_PATH }}" || echo "MISSING dump: ${{ inputs.DUMP_PATH }}"
80+
echo "===== port-ish keys from .env (values shown; these are ports, not secrets)"
81+
grep -E '^(PG_PORT|SOLR_PORT|DSPACE_PORT|DSPACE_FE_PORT|DSPACE_REST_PORT|DSPACE_DOCKER_REST_PORT|DSPACE_VER|DSPACE_HOST)=' "$ENVFILE" || echo "no port keys found"
82+
83+
- name: who owns the host ports
84+
run: |
85+
echo "===== all dspace-ish containers and their published ports"
86+
docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Ports}}' | grep -Ei 'dspace|postgres|solr' || echo "none"
87+
echo "===== anything publishing host port 5432"
88+
docker ps --format '{{.Names}}\t{{.Ports}}' | grep -E '(^|[^0-9])5432->' || echo "nothing publishes 5432"
89+
echo "===== host listeners on 5432"
90+
(ss -lntp 2>/dev/null || netstat -lntp 2>/dev/null) | grep -E ':5432' || echo "no listener on 5432 (or no permission to see it)"
91+
92+
- name: resolved compose ports for this instance
93+
run: |
94+
echo "===== merged compose config (dspacedb ports) for -p dspace-$INSTANCE"
95+
docker compose --env-file "$ENVFILE" -p dspace-$INSTANCE \
96+
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
97+
-f "$CONFIG_PATH/docker-compose-rest.yml" -f "$CONFIG_PATH/docker-compose.yml" \
98+
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|target:|^\s+ports:' | head -60 \
99+
|| echo "compose config failed"
100+
echo "===== what start.sh alone would publish (NO instance overlay)"
101+
docker compose --env-file "$ENVFILE" -p dspace-$INSTANCE \
102+
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
103+
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|target:|^\s+ports:' | head -40 \
104+
|| echo "compose config failed"
105+
106+
- name: postgres inside the instance db container
107+
run: |
108+
docker exec dspacedb$INSTANCE sh -c 'echo "PGPORT=$PGPORT"; pg_isready -U dspace; psql -U dspace -d postgres -tAc "SHOW port;" 2>/dev/null' || echo "could not probe dspacedb$INSTANCE"
109+
110+
deploy-8603:
111+
if: (inputs.INSTANCE == '*' || inputs.INSTANCE == '8603') && !inputs.PROBE_ONLY
112+
needs: probe
113+
runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1
114+
timeout-minutes: 60
115+
env:
116+
INSTANCE: '8603'
117+
CONFIG_PATH: /opt/dspace-envs/${{inputs.INSTANCE}}
118+
ENVFILE: /opt/dspace-envs/${{inputs.INSTANCE}}/.env
119+
steps:
120+
- uses: actions/checkout@v6
80121

81122
- uses: ./.github/actions/erase-db
82123
if: inputs.ERASE_DB

0 commit comments

Comments
 (0)