Add WorkerProxy assignment, readiness, and state polling APIs - #12018
Add WorkerProxy assignment, readiness, and state polling APIs#12018Shyju Krishnankutty (kshyju) wants to merge 8 commits into
Conversation
Add immutable assignment state, revision polling, relay lifecycle readiness, and injectable capability finalization. Expose management-only readiness, assignment, and instance-state endpoints with Host-aligned validation errors and source-generated JSON serialization. Includes state, relay, serialization, and endpoint integration coverage for #11974. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The required pod name is absent from the checked-in development launch profile, causing normal local startup to fail.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds WorkerProxy lifecycle management for compute-separated workers, implementing #11974.
Changes:
- Adds immutable assignment/readiness state with revision-based polling.
- Adds management-only readiness, assignment, and instance-state APIs.
- Integrates validated
StartStreamhandling and injectable capability finalization with extensive tests.
File summaries
| File | Description |
|---|---|
test/Functions.WorkerProxy.Tests/WorkerProxyWebApplicationFactory.cs |
Adds test pod identity. |
test/Functions.WorkerProxy.Tests/WorkerProxyOptionsTests.cs |
Tests pod-name binding. |
test/Functions.WorkerProxy.Tests/WorkerProxyEnvironmentConfigurationTests.cs |
Tests environment pod identity. |
test/Functions.WorkerProxy.Tests/WorkerProxyApplicationTests.cs |
Tests service registration and validation. |
test/Functions.WorkerProxy.Tests/State/WorkerPodStateManagerTests.Polling.cs |
Tests polling and races. |
test/Functions.WorkerProxy.Tests/State/WorkerPodStateManagerTests.cs |
Tests state transitions and concurrency. |
test/Functions.WorkerProxy.Tests/State/WorkerAssignmentTests.cs |
Tests assignment validation and equality. |
test/Functions.WorkerProxy.Tests/Rpc/FunctionRpcRelayTests.Readiness.cs |
Tests relay-driven readiness. |
test/Functions.WorkerProxy.Tests/Rpc/FunctionRpcRelayTests.Management.cs |
Tests end-to-end management behavior. |
test/Functions.WorkerProxy.Tests/Rpc/FunctionRpcRelayTests.HttpCapabilities.cs |
Updates HTTP capability scenarios. |
test/Functions.WorkerProxy.Tests/Rpc/FunctionRpcRelayTests.cs |
Updates relay fixtures for StartStream. |
test/Functions.WorkerProxy.Tests/Rpc/FunctionRpcRelayTests.CapabilityFinalization.cs |
Tests injectable capability finalization. |
test/Functions.WorkerProxy.Tests/Management/WorkerProxyJsonContextTests.cs |
Tests generated JSON contracts. |
test/Functions.WorkerProxy.Tests/Management/ManagementApiHandlersTests.cs |
Tests handler validation and outcomes. |
test/Functions.WorkerProxy.Tests/Management/ManagementApiEndpointTests.cs |
Tests routes and listener isolation. |
test/Functions.WorkerProxy.Tests/Http/WorkerEndpointReadinessProbeOptionsTests.cs |
Supplies required test identity. |
src/Functions.WorkerProxy/WorkerProxyOptionsValidator.cs |
Validates pod identity. |
src/Functions.WorkerProxy/WorkerProxyOptions.cs |
Adds required pod-name option. |
src/Functions.WorkerProxy/WorkerProxyApplication.cs |
Registers state and management services. |
src/Functions.WorkerProxy/State/WorkerStatePollResult.cs |
Models polling outcomes. |
src/Functions.WorkerProxy/State/WorkerPodStatus.cs |
Defines published pod status. |
src/Functions.WorkerProxy/State/WorkerPodStateManager.cs |
Implements lifecycle and polling state. |
src/Functions.WorkerProxy/State/WorkerPodState.cs |
Defines immutable state snapshots. |
src/Functions.WorkerProxy/State/WorkerAssignmentState.cs |
Defines assignment lifecycle states. |
src/Functions.WorkerProxy/State/WorkerAssignmentResult.cs |
Defines assignment outcomes. |
src/Functions.WorkerProxy/State/WorkerAssignment.cs |
Captures immutable assignment identity. |
src/Functions.WorkerProxy/Rpc/IWorkerCapabilityFinalizer.cs |
Introduces capability-finalization abstraction. |
src/Functions.WorkerProxy/Rpc/FunctionRpcRelay.Session.cs |
Integrates readiness and finalization. |
src/Functions.WorkerProxy/Rpc/FunctionRpcRelay.cs |
Injects state and finalizer dependencies. |
src/Functions.WorkerProxy/Management/WorkerProxyJsonContext.cs |
Adds source-generated JSON metadata. |
src/Functions.WorkerProxy/Management/WorkerPodStateResponse.cs |
Defines public pod-state payload. |
src/Functions.WorkerProxy/Management/WorkerInstanceState.cs |
Defines instance-state response. |
src/Functions.WorkerProxy/Management/WorkerAssignRequest.cs |
Defines assignment request payload. |
src/Functions.WorkerProxy/Management/WorkerApiErrorResponse.cs |
Defines lifecycle error envelope. |
src/Functions.WorkerProxy/Management/WorkerApiErrorCodes.cs |
Defines stable error codes. |
src/Functions.WorkerProxy/Management/WorkerApiError.cs |
Defines API error details. |
src/Functions.WorkerProxy/Management/RequestValidationResponse.cs |
Defines validation response envelope. |
src/Functions.WorkerProxy/Management/RequestValidationError.cs |
Defines field validation errors. |
src/Functions.WorkerProxy/Management/ManagementApiHandlers.cs |
Implements management API behavior. |
src/Functions.WorkerProxy/Management/ManagementApiEndpoints.cs |
Maps management-only routes. |
src/Functions.WorkerProxy/Management/InstanceStatePollRequest.cs |
Defines polling requests. |
src/Functions.WorkerProxy/Http/WorkerHttpCapabilityProvider.cs |
Implements the finalizer abstraction. |
Review details
Suppressed comments (4)
test/Functions.WorkerProxy.Tests/State/WorkerAssignmentTests.cs:54
- Use explicit ordinal string comparisons for each field selector instead of
==.
test/Functions.WorkerProxy.Tests/State/WorkerPodStateManagerTests.Polling.cs:76 - Use
string.Equalswith an explicit ordinal comparison for this transition selector.
test/Functions.WorkerProxy.Tests/Management/ManagementApiHandlersTests.cs:393 - Use
string.Equalswith an explicit ordinal comparison for this transition selector.
if (transition == "terminate")
test/Functions.WorkerProxy.Tests/Management/ManagementApiEndpointTests.cs:194
- Use an explicit ordinal comparison when deciding whether to attach a request body.
Content = method == "POST" ? JsonBody("{}") : null
- Files reviewed: 42/42 changed files
- Comments generated: 7
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Supply a development pod name in the launch profile and use explicit ordinal string comparisons in the affected tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pump the captured test synchronization context until the delayed inbound continuation finishes before asserting replacement readiness. Preserve nonblocking production termination behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The concurrency-sensitive lifecycle state machine and platform-facing management contract warrant final human validation.
Review details
- Files reviewed: 43/43 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Assignment requests with an unknown JSON charset currently return 500 instead of the documented 400 validation envelope.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 42/42 changed files
- Comments generated: 1
- Review effort level: Balanced
…rtions Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new routes conflict with the linked, still-open platform contract and acceptance criteria.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 42/42 changed files
- Comments generated: 1
- Review effort level: Balanced
| namespace Azure.Functions.WorkerProxy.Management; | ||
|
|
||
| /// <summary> | ||
| /// Wraps validation and lifecycle failures in the same management API error envelope. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Adds single-worker assignment and readiness management to WorkerProxy for compute separation.
Management APIs
GET /admin/worker/readyPUT /admin/worker/assignmentLocationon creation, 204 for equivalent live replay. Conflicting assignments and terminal replays return 409 with distinct error codes.GET /admin/worker/statelastKnownRevisionfor an immediate snapshot. An older revision returns immediately; an equal revision waits up to 60 seconds for a change, returning 204 on timeout.Implementation details
WorkerProxy:PodNameconfiguration.InvalidBodyenvelope for malformed bodies, incompatible types, and unsupported content types or charsets.WorkerNotReady(503),WorkerTerminated(409), andAssignmentConflict(409). A conflicting identity takes precedence over terminal replay.lastKnownRevisionas an optional, single nonnegative int64 query value no greater than the current revision. Invalid values return 400; explicit zero participates in normal polling.Cache-Control: no-storeon readiness and state responses, including errors and polling timeouts. Replaces the earlier POST routes rather than retaining aliases.Includes unit and integration coverage for concurrent assignment creation/replay, conflicts, relay lifecycle, polling/query validation, serialization, cache headers, and listener isolation.
Issue describing the changes in this PR
Resolves #11974.
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-procbranch to be included in Core Tools and non-Flex deployments.in-procbranch is not required; otherwise, link the backport PR.release_notes.md.Additional information
The HTTP contract follows the resource-oriented proposal in serverless-paas-balam/FlexConsumption-BYOC#242. Platform contract agreement remains tracked by #11971; these changes do not imply platform sign-off or production-security approval.