Skip to content

Commit d08cf04

Browse files
Pigbibicodex
andauthored
fix(ops): fail closed before manual VM reset (#97)
Co-authored-by: Codex <noreply@openai.com>
1 parent 6cc778e commit d08cf04

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ on:
2828
options:
2929
- keepalive
3030
- full
31+
allow_vm_reset:
32+
description: permit automatic VM reset after SSH/SCP/deploy failure
33+
required: false
34+
default: false
35+
type: boolean
3136
sync_github_secrets_to_secret_manager:
3237
description: write current GitHub secrets into Secret Manager before deploy
3338
required: false
@@ -223,6 +228,7 @@ jobs:
223228
VNC_SERVER_PASSWORD_SECRET_NAME: ${{ matrix.target.vnc_server_password_secret_name }}
224229
WORKFLOW_DISPATCH_MODE: ${{ github.event.inputs.deploy_mode }}
225230
WORKFLOW_DISPATCH_TARGET: ${{ github.event.inputs.target }}
231+
WORKFLOW_DISPATCH_ALLOW_VM_RESET: ${{ github.event.inputs.allow_vm_reset }}
226232
steps:
227233
- name: Checkout code
228234
uses: actions/checkout@v6
@@ -511,6 +517,12 @@ jobs:
511517
)
512518
513519
reset_instance_and_wait_for_ssh() {
520+
if [ "${DEPLOY_EVENT_NAME}" = "workflow_dispatch" ] \
521+
&& [ "${WORKFLOW_DISPATCH_ALLOW_VM_RESET:-false}" != "true" ]; then
522+
echo "Manual workflow VM reset is disabled; failing closed." >&2
523+
return 1
524+
fi
525+
514526
log_step "Resetting ${GCE_INSTANCE_NAME} after SSH/SCP failure"
515527
gcloud compute instances reset "${GCE_INSTANCE_NAME}" \
516528
--project "${GCP_PROJECT_ID}" \

tests/test_workflow_shared_config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ grep -Fq 'workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}'
2121
grep -Fq 'service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}' "$workflow_file"
2222
grep -Fq "DEPLOY_EVENT_NAME: \${{ github.event_name }}" "$workflow_file"
2323
grep -Fq "WORKFLOW_DISPATCH_MODE: \${{ github.event.inputs.deploy_mode }}" "$workflow_file"
24+
grep -Fq "WORKFLOW_DISPATCH_ALLOW_VM_RESET: \${{ github.event.inputs.allow_vm_reset }}" "$workflow_file"
2425
grep -Fq 'vars.IB_GATEWAY_INSTANCE_NAME' "$workflow_file"
2526
grep -Fq 'vars.IB_GATEWAY_ZONE' "$workflow_file"
2627
grep -Fq 'vars.IB_GATEWAY_MODE' "$workflow_file"
@@ -64,6 +65,7 @@ grep -Fq 'elif [ "${DEPLOY_EVENT_NAME}" = "workflow_dispatch" ]; then' "$workflo
6465
grep -Fq 'DEPLOY_MODE="${WORKFLOW_DISPATCH_MODE:-keepalive}"' "$workflow_file"
6566
grep -Fq 'Scheduled keepalive mode: skip docker build' "$workflow_file"
6667
grep -Fq 'reset_instance_and_wait_for_ssh()' "$workflow_file"
68+
grep -Fq 'Manual workflow VM reset is disabled; failing closed.' "$workflow_file"
6769
grep -Fq 'run_remote_ssh()' "$workflow_file"
6870
grep -Fq 'copy_remote_file()' "$workflow_file"
6971
grep -Fq 'git archive --format=tar.gz' "$workflow_file"

0 commit comments

Comments
 (0)