Exit ephemeral runners on broker acknowledge job-not-found#4540
Exit ephemeral runners on broker acknowledge job-not-found#4540rentziass wants to merge 7 commits into
Conversation
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.
Pull request overview
This PR adds explicit classification for broker acknowledge “404 / Job not found” responses and uses that classification to let single-use runners (ephemeral / --once) exit cleanly instead of continuing to poll in a terminal condition.
Changes:
- Add a new
RunnerRequestJobNotFoundExceptionand throw it fromBrokerHttpClient.AcknowledgeRunnerRequestAsyncwhen the broker returns a “Job not found” 404. - Update the listener runner loop to exit early for single-use runners when acknowledge hits the job-not-found terminal condition, while preserving best-effort behavior for persistent runners.
- Add L0 coverage for the new broker classification and the single-use vs persistent runner behaviors.
Show a summary per file
| File | Description |
|---|---|
| src/Sdk/WebApi/WebApi/BrokerHttpClient.cs | Adds job-not-found detection and throws a dedicated exception on acknowledge. |
| src/Sdk/WebApi/WebApi/Exceptions/RunnerRequestJobNotFoundException.cs | Introduces a new exception type representing the acknowledge terminal condition. |
| src/Runner.Listener/Runner.cs | Exits single-use runners on job-not-found acknowledge and ensures ephemeral cleanup triggers. |
| src/Test/L0/Sdk/RSWebApi/BrokerHttpClientL0.cs | Adds unit tests validating acknowledge error classification behavior. |
| src/Test/L0/Listener/RunnerL0.cs | Adds runner loop tests for single-use exit vs persistent continuation on acknowledge job-not-found. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Low
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| if (IsAcknowledgeJobNotFound(result.StatusCode, brokerError)) | ||
| { | ||
| throw new RunnerRequestJobNotFoundException(brokerError.Message); | ||
| } |
There was a problem hiding this comment.
should this merge with the switch above somehow? since they are both kind of checking the brokererror and throw exception.
| return statusCode == HttpStatusCode.NotFound && | ||
| brokerError?.StatusCode == (int)HttpStatusCode.NotFound && | ||
| !string.Equals(brokerError.ErrorKind, BrokerErrorKind.RunnerNotFound, StringComparison.Ordinal) && | ||
| string.Equals(brokerError.Message, "Job not found", StringComparison.OrdinalIgnoreCase); |
There was a problem hiding this comment.
Can you help me understand more about this?
Is there an error kind we could rely on, instead of message?
I'm worried relying on the error message might be fragile. That's why error kind exists.
There was a problem hiding this comment.
Good point, let me have a look at the API.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
AcknowledgeJobNotFoundbroker error kind, while keeping compatibility with the legacy broker 404 response until the backend feature flag is enabledScope
Testing
Fixes #4312