fix(workloadmanager): map missing public key to 503#336
fix(workloadmanager): map missing public key to 503#336mrinalchaturvedi27 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Maps api.ErrPublicKeyMissing (raised by workload_builder.go when the Router public key has not been loaded yet) to HTTP 503 in handleSandboxCreate, so clients can distinguish a transient startup condition from a true internal server error and safely retry.
Changes:
- In
handleSandboxCreate, add anerrors.Is(err, api.ErrPublicKeyMissing)branch that responds withhttp.StatusServiceUnavailableand the error message. - Add a corresponding table-test case in
TestHandleSandboxCreateverifying the 503 response and message body.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/workloadmanager/handlers.go | Adds branch mapping ErrPublicKeyMissing to HTTP 503 instead of falling through to 500. |
| pkg/workloadmanager/handlers_test.go | New table-driven test case asserting 503 + error message for the public-key-missing path. |
There was a problem hiding this comment.
Code Review
This pull request updates the handleSandboxCreate function in pkg/workloadmanager/handlers.go to explicitly handle the api.ErrPublicKeyMissing error by returning an HTTP 503 Service Unavailable status. Additionally, a new test case has been added to pkg/workloadmanager/handlers_test.go to verify this behavior. I have no feedback to provide as there were no review comments to evaluate.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #336 +/- ##
==========================================
+ Coverage 47.57% 49.21% +1.64%
==========================================
Files 30 30
Lines 2819 2863 +44
==========================================
+ Hits 1341 1409 +68
+ Misses 1338 1301 -37
- Partials 140 153 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
88bf9e8 to
dba5efd
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
This fixes workload-manager so
ErrPublicKeyMissingreturns HTTP 503 instead of HTTP 500. This tells clients that the Router public key is not ready yet and the request can be retried later.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The focused Go test could not finish locally because the machine ran out of disk space during compilation. I added a table test for the new 503 mapping.
Does this PR introduce a user-facing change?:
What I fixed
I fixed sandbox creation in workload-manager for the case where the Router public key is not ready yet. Earlier,
ErrPublicKeyMissingreturned HTTP 500 withinternal server error. Now it returns HTTP 503.How I found it
I checked
handleSandboxCreateinpkg/workloadmanager/handlers.go. It already handled missing AgentRuntime and CodeInterpreter errors, but it did not handleapi.ErrPublicKeyMissing.That error comes from
pkg/workloadmanager/workload_builder.gowhen PicoD auth needs the Router public key and the key has not been loaded yet.What I changed
errors.Is(err, api.ErrPublicKeyMissing).http.StatusServiceUnavailablefor that error.TestHandleSandboxCreate.Why this is correct
This matches the issue goal directly. A missing public key during startup is not a real server bug. It is a temporary state, so HTTP 503 is a better response than HTTP 500.
Validation
All tests passed