Skip to content

Commit 4c5de6c

Browse files
eakmanrqclaude
andcommitted
Fix gcp-postgres teardown: skip re-download and re-start of proxy
The init function runs for both 'up' and 'down'. On teardown, curl fails writing the binary (exit code 23) because the running proxy holds it. Skip download if binary exists and skip proxy start if already running. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: eakmanrq <6326532+eakmanrq@users.noreply.github.com>
1 parent 98ea8b3 commit 4c5de6c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.github/scripts/manage-test-db.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ clickhouse-cloud_init() {
103103

104104
# GCP Postgres
105105
gcp-postgres_init() {
106-
# Download and start Cloud SQL Proxy
107-
curl -fsSL -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.linux.amd64
108-
chmod +x cloud-sql-proxy
106+
# Download Cloud SQL Proxy if not already present
107+
if [ ! -f cloud-sql-proxy ]; then
108+
curl -fsSL -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.linux.amd64
109+
chmod +x cloud-sql-proxy
110+
fi
109111
echo "$GCP_POSTGRES_KEYFILE_JSON" > /tmp/keyfile.json
110-
./cloud-sql-proxy --credentials-file /tmp/keyfile.json $GCP_POSTGRES_INSTANCE_CONNECTION_STRING &
111-
112-
# Wait for proxy to start
113-
sleep 5
112+
if ! pgrep -x cloud-sql-proxy > /dev/null; then
113+
./cloud-sql-proxy --credentials-file /tmp/keyfile.json $GCP_POSTGRES_INSTANCE_CONNECTION_STRING &
114+
sleep 5
115+
fi
114116
}
115117

116118
gcp-postgres_exec() {

0 commit comments

Comments
 (0)