Skip to content

Commit e001c6d

Browse files
Pigbibicodex
andauthored
fix(ops): support clean targeted Gateway rebuilds (#98)
* chore(ops): inspect remote gateway source file Co-Authored-By: Codex <noreply@openai.com> * fix(ops): allow clean targeted gateway rebuild Co-Authored-By: Codex <noreply@openai.com> * fix(ops): expand clean rebuild flag explicitly Co-Authored-By: Codex <noreply@openai.com> --------- Co-authored-by: Codex <noreply@openai.com>
1 parent d08cf04 commit e001c6d

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/diagnose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,25 @@ jobs:
231231
232232
section "runtime executable metadata"
233233
printf 'host_arch=%s\n' "$(uname -m)"
234+
if [ -f container_overrides/run.sh ]; then
235+
stat -c 'source_run_mode=%a source_run_size=%s' container_overrides/run.sh 2>/dev/null \
236+
|| echo "source_run_stat_unavailable"
237+
if command -v od >/dev/null 2>&1; then
238+
printf 'source_run_first_bytes='
239+
od -An -tx1 -N16 container_overrides/run.sh 2>/dev/null | tr -d ' \n' || true
240+
printf '\n'
241+
else
242+
echo "source_run_first_bytes_unavailable"
243+
fi
244+
if command -v sha256sum >/dev/null 2>&1; then
245+
sha256sum container_overrides/run.sh 2>/dev/null \
246+
| awk '{print "source_run_sha256=" $1}' || true
247+
else
248+
echo "source_run_sha256_unavailable"
249+
fi
250+
else
251+
echo "source_run_file_unavailable"
252+
fi
234253
if sudo docker inspect "$CONTAINER_NAME" >/dev/null 2>&1; then
235254
sudo docker inspect --format \
236255
'container_state={{.State.Status}} exit_code={{.State.ExitCode}} oom_killed={{.State.OOMKilled}} restart_count={{.RestartCount}}' \

.github/workflows/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ on:
3333
required: false
3434
default: false
3535
type: boolean
36+
rebuild_without_cache:
37+
description: force a clean image rebuild during full manual deploy
38+
required: false
39+
default: false
40+
type: boolean
3641
sync_github_secrets_to_secret_manager:
3742
description: write current GitHub secrets into Secret Manager before deploy
3843
required: false
@@ -229,6 +234,7 @@ jobs:
229234
WORKFLOW_DISPATCH_MODE: ${{ github.event.inputs.deploy_mode }}
230235
WORKFLOW_DISPATCH_TARGET: ${{ github.event.inputs.target }}
231236
WORKFLOW_DISPATCH_ALLOW_VM_RESET: ${{ github.event.inputs.allow_vm_reset }}
237+
WORKFLOW_DISPATCH_REBUILD_WITHOUT_CACHE: ${{ github.event.inputs.rebuild_without_cache }}
232238
steps:
233239
- name: Checkout code
234240
uses: actions/checkout@v6
@@ -683,7 +689,12 @@ jobs:
683689
sudo systemctl stop "\${IBKR_GATEWAY_HEALTHCHECK_TIMER}" "\${IBKR_GATEWAY_HEALTHCHECK_SERVICE}" 2>/dev/null || true
684690
sudo systemctl stop "\${IBKR_GATEWAY_DAILY_RESTART_TIMER}" "\${IBKR_GATEWAY_DAILY_RESTART_SERVICE}" 2>/dev/null || true
685691
sudo bash ./scripts/ensure_host_swap.sh
686-
sudo docker compose build "\${compose_service_name}"
692+
if [ "${WORKFLOW_DISPATCH_REBUILD_WITHOUT_CACHE:-false}" = 'true' ]; then
693+
echo "[\$(date -u +%FT%TZ)] Building without cache"
694+
sudo docker compose build --no-cache "\${compose_service_name}"
695+
else
696+
sudo docker compose build "\${compose_service_name}"
697+
fi
687698
sudo docker compose down
688699
sudo docker compose up -d "\${compose_service_name}"
689700

tests/test_workflow_shared_config.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ grep -Fq 'service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}' "$w
2222
grep -Fq "DEPLOY_EVENT_NAME: \${{ github.event_name }}" "$workflow_file"
2323
grep -Fq "WORKFLOW_DISPATCH_MODE: \${{ github.event.inputs.deploy_mode }}" "$workflow_file"
2424
grep -Fq "WORKFLOW_DISPATCH_ALLOW_VM_RESET: \${{ github.event.inputs.allow_vm_reset }}" "$workflow_file"
25+
grep -Fq "WORKFLOW_DISPATCH_REBUILD_WITHOUT_CACHE: \${{ github.event.inputs.rebuild_without_cache }}" "$workflow_file"
2526
grep -Fq 'vars.IB_GATEWAY_INSTANCE_NAME' "$workflow_file"
2627
grep -Fq 'vars.IB_GATEWAY_ZONE' "$workflow_file"
2728
grep -Fq 'vars.IB_GATEWAY_MODE' "$workflow_file"
@@ -66,6 +67,8 @@ grep -Fq 'DEPLOY_MODE="${WORKFLOW_DISPATCH_MODE:-keepalive}"' "$workflow_file"
6667
grep -Fq 'Scheduled keepalive mode: skip docker build' "$workflow_file"
6768
grep -Fq 'reset_instance_and_wait_for_ssh()' "$workflow_file"
6869
grep -Fq 'Manual workflow VM reset is disabled; failing closed.' "$workflow_file"
70+
grep -Fq 'sudo docker compose build --no-cache "\${compose_service_name}"' "$workflow_file"
71+
grep -Fq 'if [ "${WORKFLOW_DISPATCH_REBUILD_WITHOUT_CACHE:-false}" = '\''true'\'' ]; then' "$workflow_file"
6972
grep -Fq 'run_remote_ssh()' "$workflow_file"
7073
grep -Fq 'copy_remote_file()' "$workflow_file"
7174
grep -Fq 'git archive --format=tar.gz' "$workflow_file"
@@ -167,6 +170,8 @@ grep -Fq '| redact_diagnostics' "$diagnose_workflow_file"
167170
grep -Fq 'section "runtime executable metadata"' "$diagnose_workflow_file"
168171
grep -Fq 'image_os={{.Os}} image_arch={{.Architecture}}' "$diagnose_workflow_file"
169172
grep -Fq 'run_first_bytes=' "$diagnose_workflow_file"
173+
grep -Fq 'source_run_size=%s' "$diagnose_workflow_file"
174+
grep -Fq 'source_run_sha256=' "$diagnose_workflow_file"
170175
grep -Fq 'CONTAINER_NAME=__CONTAINER_NAME__' "$diagnose_workflow_file"
171176
grep -Fq 'sudo docker inspect "$CONTAINER_NAME"' "$diagnose_workflow_file"
172177
grep -Fq 'sudo docker cp "$CONTAINER_NAME":/home/ibgateway/scripts/run.sh' "$diagnose_workflow_file"

0 commit comments

Comments
 (0)