Skip to content

Commit 603ff45

Browse files
Pigbibicursoragent
andauthored
fix: verify plugin mounts from sync plan for current service (#214)
Pass SYNC_PLAN_JSON into the post-sync verification step and scope checks to CLOUD_RUN_SERVICE with per-target Cloud Run regions. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 56ee87a commit 603ff45

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ jobs:
946946
- name: Verify strategy plugin mounts
947947
if: steps.config.outputs.env_sync_enabled == 'true'
948948
env:
949+
SYNC_PLAN_JSON: ${{ steps.strategy_requirements.outputs.sync_plan_json }}
949950
STRATEGY_PLUGIN_MOUNT_ENV_NAMES: LONGBRIDGE_STRATEGY_PLUGIN_MOUNTS_JSON
950951
run: |
951952
set -euo pipefail

scripts/verify_cloud_run_strategy_plugin_mounts.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,32 @@ def _verify_target(
230230
return checked
231231

232232

233+
def _region_for_service(service: str) -> str:
234+
default_region = (os.environ.get("CLOUD_RUN_REGION") or "").strip()
235+
raw_targets = (os.environ.get("CLOUD_RUN_SERVICE_TARGETS_JSON") or "").strip()
236+
if not raw_targets:
237+
return default_region
238+
payload = json.loads(raw_targets)
239+
for item in payload.get("targets") or []:
240+
if not isinstance(item, Mapping):
241+
continue
242+
service_name = str(item.get("service_name") or item.get("service") or "").strip()
243+
if service_name != service:
244+
continue
245+
region = str(item.get("region") or "").strip()
246+
if region:
247+
return region
248+
return default_region
249+
250+
251+
def _filter_targets_for_current_service(targets: list[dict[str, Any]]) -> list[dict[str, Any]]:
252+
current_service = (os.environ.get("CLOUD_RUN_SERVICE") or "").strip()
253+
if not current_service:
254+
return targets
255+
filtered = [target for target in targets if target.get("service") == current_service]
256+
return filtered or targets
257+
258+
233259
def main() -> int:
234260
region = (os.environ.get("CLOUD_RUN_REGION") or "").strip()
235261
if not region:
@@ -241,10 +267,11 @@ def main() -> int:
241267
allowed_prefixes = _allowed_signal_prefixes()
242268

243269
try:
244-
targets = _load_expected_targets(mount_env_names)
270+
targets = _filter_targets_for_current_service(_load_expected_targets(mount_env_names))
245271
for target in targets:
246272
service = target["service"]
247-
service_json = _describe_service(service, region, project or None)
273+
service_region = _region_for_service(service) or region
274+
service_json = _describe_service(service, service_region, project or None)
248275
actual_env = _container_env(service_json)
249276
checked = _verify_target(
250277
service=service,

0 commit comments

Comments
 (0)