Skip to content

Add WorkerProxy assignment, readiness, and state polling APIs - #12018

Open
Shyju Krishnankutty (kshyju) wants to merge 8 commits into
devfrom
shkr/workerproxy_readyness
Open

Add WorkerProxy assignment, readiness, and state polling APIs#12018
Shyju Krishnankutty (kshyju) wants to merge 8 commits into
devfrom
shkr/workerproxy_readyness

Conversation

@kshyju

@kshyju Shyju Krishnankutty (kshyju) commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Adds single-worker assignment and readiness management to WorkerProxy for compute separation.

Management APIs

Endpoint Behavior
GET /admin/worker/ready Returns 200 when the worker connection is ready, otherwise 503. Does not require assignment or indicate Host serving readiness.
PUT /admin/worker/assignment Creates an immutable assignment for an already-configured worker: 201 with Location on creation, 204 for equivalent live replay. Conflicting assignments and terminal replays return 409 with distinct error codes.
GET /admin/worker/state Omit lastKnownRevision for 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

  • Integrates readiness with relay attachment, valid worker startup, and termination. Assignment before readiness returns 503 without claiming an identity; assigned-session failure is terminal.
  • Publishes assignment and state changes atomically, distinguishing creation from replay under the same lock. Equivalent retries preserve revisions; polling cancellation cleans up waiters.
  • Retains all five assignment fields. Environment settings and the application directory participate in assignment identity only; the proxy does not apply configuration or initiate worker initialization.
  • Adds injectable capability finalization while preserving existing HTTP capability rewriting.
  • Uses management-listener-only routes, source-generated JSON serialization, and required WorkerProxy:PodName configuration.
  • Matches the Host link endpoint's validation envelope, returning all detected field errors together. Explicit assignment JSON parsing and charset validation preserve the 400 InvalidBody envelope for malformed bodies, incompatible types, and unsupported content types or charsets.
  • Preserves stable assignment error codes: WorkerNotReady (503), WorkerTerminated (409), and AssignmentConflict (409). A conflicting identity takes precedence over terminal replay.
  • Validates lastKnownRevision as an optional, single nonnegative int64 query value no greater than the current revision. Invalid values return 400; explicit zero participates in normal polling.
  • Sends Cache-Control: no-store on 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-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required; otherwise, link the backport PR.
  • My changes do not require documentation changes; otherwise, link the documentation issue.
  • My changes should not be added to the release notes; otherwise, add notes to release_notes.md.
  • My changes do not need to be backported to a previous version; otherwise, link the tracking issue/PR.
  • My changes do not require diagnostic events changes; otherwise, update the events and related documentation.
  • I have added all required tests (unit tests, E2E tests).

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.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 StartStream handling 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.Equals with an explicit ordinal comparison for this transition selector.
    test/Functions.WorkerProxy.Tests/Management/ManagementApiHandlersTests.cs:393
  • Use string.Equals with 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.

Comment thread src/Functions.WorkerProxy/WorkerProxyOptions.cs
Comment thread test/Functions.WorkerProxy.Tests/Management/ManagementApiEndpointTests.cs Outdated
Comment thread test/Functions.WorkerProxy.Tests/Management/ManagementApiEndpointTests.cs Outdated
Comment thread test/Functions.WorkerProxy.Tests/Management/ManagementApiEndpointTests.cs Outdated
Comment thread test/Functions.WorkerProxy.Tests/Management/ManagementApiHandlersTests.cs Outdated
Comment thread test/Functions.WorkerProxy.Tests/State/WorkerAssignmentTests.cs Outdated
Comment thread test/Functions.WorkerProxy.Tests/State/WorkerPodStateManagerTests.Polling.cs Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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>
@kshyju
Shyju Krishnankutty (kshyju) marked this pull request as ready for review September 11, 2026 20:33
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/Functions.WorkerProxy/Management/ManagementApiEndpoints.cs
…rtions

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/Functions.WorkerProxy/Management/ManagementApiEndpoints.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-component wire contract remains gated by unresolved platform agreement in #11971.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compute Separation][HP3+HP5A-M1] Add one-worker assignment and readiness APIs

2 participants