fix(router,workloadmanager): populate sandbox Kind and Namespace on create#338
fix(router,workloadmanager): populate sandbox Kind and Namespace on create#338Abhinav-kodes wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the createSandbox function in pkg/router/session_manager.go to populate the Kind field in the SandboxInfo struct. Feedback indicates that using the 'invoke kind' for this field may cause inconsistencies and break deletion logic in the workload manager. It was also recommended to populate the SandboxNamespace field to maintain consistency with data retrieved from the store.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #338 +/- ##
==========================================
+ Coverage 47.57% 49.17% +1.60%
==========================================
Files 30 30
Lines 2819 2861 +42
==========================================
+ Hits 1341 1407 +66
+ 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:
|
…reate Signed-off-by: Abhinav Singh <abhinavsingh717073@gmail.com>
888d6cb to
c4e0bd5
Compare
|
[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 |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a Kind field to the CreateSandboxResponse struct and ensures it is correctly populated and propagated within the session_manager and workloadmanager. Additionally, the SandboxNamespace is now included in the SandboxInfo object. The reviewer suggests further improving consistency by populating SandboxInfo with additional metadata from the response, such as timestamps and status, to ensure the in-memory object matches the persisted state.
| sandbox := &types.SandboxInfo{ | ||
| SandboxID: res.SandboxID, | ||
| Name: res.SandboxName, | ||
| SessionID: res.SessionID, | ||
| EntryPoints: res.EntryPoints, | ||
| Kind: res.Kind, | ||
| SandboxNamespace: namespace, | ||
| SandboxID: res.SandboxID, | ||
| Name: res.SandboxName, | ||
| SessionID: res.SessionID, | ||
| EntryPoints: res.EntryPoints, | ||
| } |
There was a problem hiding this comment.
Populate the SandboxInfo object using the actual namespace and metadata returned by the workload manager. This ensures that the in-memory object is fully consistent with what was persisted in the store, including timestamps and status.
sandbox := &types.SandboxInfo{
Kind: res.Kind,
SandboxNamespace: res.SandboxNamespace,
SandboxID: res.SandboxID,
Name: res.SandboxName,
SessionID: res.SessionID,
EntryPoints: res.EntryPoints,
CreatedAt: res.CreatedAt,
ExpiresAt: res.ExpiresAt,
Status: res.Status,
}There was a problem hiding this comment.
The router only uses this SandboxInfo to resolve the upstream target and decide whether to sign with JWT, it doesn't need lifecycle metadata like CreatedAt, ExpiresAt, or Status. Those fields are populated when the sandbox is fetched from the store (existing session path). Keeping the response minimal avoids coupling the router to internal workload manager state.
For SandboxNamespace, the router already has it from the request parameter, no need to round-trip it through the response.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
When the router creates a new sandbox via the workload manager, the returned
SandboxInfohad emptyKindandSandboxNamespacefields. This causesgenerateSandboxJWTto skip JWT signing for freshly-created sandboxes, since it checkssandbox.KindagainstSandboxKind/SandboxClaimsKind.This PR:
KindtoCreateSandboxResponseand populates it from the workload manager with the real resource kind (SandboxorSandboxClaim)SandboxNamespacein the router for consistency with store-fetched sandboxesSpecial notes for your reviewer:
Kinduses the resource kind (Sandbox/SandboxClaim), not the invoke kind (AgentRuntime/CodeInterpreter), to stay consistent with the store path and the workload manager's deletion logic.Does this PR introduce a user-facing change?: