Skip to content

Commit 67a3713

Browse files
Pigbibicodex
andcommitted
fix: preserve monitor fallback during migration
Co-Authored-By: Codex <noreply@openai.com>
1 parent 7bbe46d commit 67a3713

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/sync-cloud-run-env.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,6 @@ jobs:
861861
remove_env_vars+=("STRATEGY_PLUGIN_ALERT_TELEGRAM_BODY_MAX_CHARS")
862862
fi
863863
864-
remove_env_vars+=("MONITOR_DISPATCH_TARGETS_JSON" "LONGBRIDGE_MONITOR_DISPATCH_TARGETS_JSON")
865-
866864
gcloud_args=(
867865
run services update "${CLOUD_RUN_SERVICE}"
868866
--region "${CLOUD_RUN_REGION}"
@@ -1315,6 +1313,8 @@ jobs:
13151313
or scheduler.get("location")
13161314
or target.get("region")
13171315
or target.get("cloud_run_region")
1316+
or os.environ.get("CLOUD_SCHEDULER_LOCATION")
1317+
or os.environ.get("CLOUD_RUN_REGION")
13181318
or ""
13191319
).strip()
13201320
if service_name:

tests/test_scheduler_workflow.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ def test_replacement_probe_and_precheck_exist_before_shared_dispatcher_cleanup()
1313
assert precheck < cleanup_job < cleanup
1414

1515
cleanup_section = workflow[cleanup_job:]
16+
sync_section = workflow[:cleanup_job]
1617
assert "needs: sync" in cleanup_section
1718
assert "environment: longbridge-sg" in cleanup_section
1819
assert 'replacement_jobs=("${service_name}-probe-scheduler" "${service_name}-precheck-scheduler")' in cleanup_section
1920
assert "if: steps.replacements.outputs.ready == 'true'" in cleanup_section
21+
assert "MONITOR_DISPATCH_TARGETS_JSON" not in sync_section
22+
assert "LONGBRIDGE_MONITOR_DISPATCH_TARGETS_JSON" not in sync_section
23+
24+
25+
def test_replacement_verifier_falls_back_to_global_scheduler_location() -> None:
26+
workflow = Path(".github/workflows/sync-cloud-run-env.yml").read_text(encoding="utf-8")
27+
cleanup_section = workflow[workflow.index("cleanup-shared-monitor:") :]
28+
29+
assert 'or os.environ.get("CLOUD_SCHEDULER_LOCATION")' in cleanup_section
30+
assert 'or os.environ.get("CLOUD_RUN_REGION")' in cleanup_section
2031

2132

2233
def test_existing_scheduler_cron_rejects_ambiguous_day_fields() -> None:

tests/test_sync_cloud_run_env_workflow.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ grep -Fq 'join_by_delimiter()' "$workflow_file"
209209
grep -Fq 'gcloud_args+=(--remove-secrets "$(IFS=,; echo "${remove_secret_vars[*]}")")' "$workflow_file"
210210
grep -Fq 'gcloud_args+=(--update-secrets "$(IFS=,; echo "${secret_pairs[*]}")")' "$workflow_file"
211211
grep -Fq -- '--update-env-vars "^|^$(join_by_delimiter "|" "${env_pairs[@]}")"' "$workflow_file"
212-
grep -Fq 'remove_env_vars+=("MONITOR_DISPATCH_TARGETS_JSON" "LONGBRIDGE_MONITOR_DISPATCH_TARGETS_JSON")' "$workflow_file"
213212
grep -Fq 'Sync Cloud Scheduler schedule' "$workflow_file"
214213
grep -Fq 'scheduler_location="${CLOUD_SCHEDULER_LOCATION:-${CLOUD_RUN_REGION}}"' "$workflow_file"
215214
grep -Fq 'target_env = target.get("env") or {}' "$workflow_file"

0 commit comments

Comments
 (0)