Skip to content

Commit 5dae11d

Browse files
committed
fix(machine-sync): backfill missing resource_id from provider state
sync_machines_with_provider only updated fields that already existed in the update block. If a machine was stored before the handler fix (or via a code path that omitted resource_id) it would never have resource_id set, keeping it invisible to group_by_resource on the return path. Add resource_id to both the needs_update predicate and the update block: only backfill when provider knows the resource_id and the existing record is missing it, leaving all other resource_id values untouched.
1 parent c1c71a8 commit 5dae11d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/orb/application/services/machine_sync_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ async def sync_machines_with_provider(
261261
or existing.vpc_id != provider_machine.vpc_id
262262
or existing.status_reason != provider_machine.status_reason
263263
or existing.provider_data != provider_machine.provider_data
264+
or (provider_machine.resource_id and not existing.resource_id)
264265
)
265266

266267
# Debug logging
@@ -288,6 +289,8 @@ async def sync_machines_with_provider(
288289
machine_data["vpc_id"] = provider_machine.vpc_id
289290
machine_data["version"] = existing.version + 1
290291
machine_data["tags"] = provider_machine.tags
292+
if provider_machine.resource_id and not existing.resource_id:
293+
machine_data["resource_id"] = provider_machine.resource_id
291294

292295
updated_machine = Machine.model_validate(machine_data)
293296
to_upsert.append(updated_machine)

0 commit comments

Comments
 (0)