Skip to content

Commit a9d8cd9

Browse files
committed
fix(providers/aws): restore main's fulfillment_final semantics for INSTANT + RunInstances
The earlier revert overshot: it set ``fulfillment_final=True`` uniformly across every AWS handler, but the main-equivalent semantics differ per provider. ``fulfillment_final=True`` means the CREATE call returned the entire fulfilment story synchronously, so the dispatch layer can stamp COMPLETED immediately when len(instances) >= count. - EC2Fleet REQUEST / MAINTAIN: ``True`` — create returns only a fleet ID and no instances; nothing more is coming synchronously. (Unchanged from the earlier revert.) - EC2Fleet INSTANT: ``False`` — create returns instance IDs but the instances are still in ``pending`` state at create time; the polling loop has to observe the running transition. - RunInstances: key omitted (defaults to False) — instance IDs are synchronous, instance state is not. INSTANT and RunInstances were both wrong on the revert: they ended up with ``fulfillment_final=True``, so dispatch tried to mark the request COMPLETED at provisioning time before instances were actually running. SpotFleet and ASG keep ``True`` because their create calls return zero instances synchronously — the same shape as a REQUEST/MAINTAIN fleet. Note that this fix does NOT resolve all live test failures we saw in the latest run. AWS eu-west-2 is currently delivering only 2 of 4 t3.medium INSTANT instances, so the request correctly settles at ``state="partial"`` (HF wire: complete_with_error) for the 4-capacity test scenarios. That is a real AWS capacity flake against the test suite's assertions, not a code bug.
1 parent d673441 commit a9d8cd9

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/orb/providers/aws/infrastructure/handlers/ec2_fleet/handler.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,17 @@ def _acquire_hosts_internal(
189189
"resource_type": "ec2_fleet",
190190
"fleet_type": fleet_type_value,
191191
"fleet_errors": fleet_errors,
192-
# ``fulfillment_final`` reports whether the provider's
193-
# CREATE call is the final word from the provisioning
194-
# layer. All fleet types return a stable fleet ID at
195-
# create time; whether instances are actually running is
196-
# a separate ``check_hosts_status`` polling concern that
197-
# drives the request from IN_PROGRESS to COMPLETED. See
198-
# ``fulfilment-model.md`` for the two-layer design.
199-
"fulfillment_final": True,
192+
# ``fulfillment_final=True`` means the provider's CREATE
193+
# call returned the entire fulfilment story synchronously.
194+
# MAINTAIN / REQUEST fleets return only a fleet ID and no
195+
# instances yet (instance arrival is purely a polling
196+
# concern), so the create call IS the final synchronous
197+
# answer for those types. INSTANT fleets return instance
198+
# IDs synchronously but those instances are still in
199+
# ``pending`` state at create time, so the create call is
200+
# NOT the final answer — the polling loop must observe the
201+
# running state. Matches the pre-redesign main semantics.
202+
"fulfillment_final": fleet_type is not AWSFleetType.INSTANT,
200203
"capacity_constrained": capacity_constrained,
201204
},
202205
}

src/orb/providers/aws/infrastructure/handlers/run_instances/handler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ def _acquire_hosts_internal(
143143
"resource_type": "run_instances",
144144
"reservation_id": resource_id,
145145
"instance_ids": instance_ids,
146-
# RunInstances returns instance IDs synchronously. The
147-
# provider create-call is final; instance running-state
148-
# is driven by check_hosts_status from IN_PROGRESS to
149-
# COMPLETED on the polling layer.
150-
"fulfillment_final": True,
146+
# RunInstances returns instance IDs synchronously but the
147+
# instances themselves are still ``pending`` at this
148+
# point. Omitting ``fulfillment_final`` defaults it to
149+
# False at the dispatch layer, which routes the request
150+
# through the polling loop so check_hosts_status can drive
151+
# IN_PROGRESS → COMPLETED once instances reach ``running``.
152+
# Matches the pre-redesign main semantics.
151153
},
152154
}
153155
except Exception as e:

0 commit comments

Comments
 (0)