[Bug Report] CubeMaster drops sandbox labels and metadata after pause, causing sandbox lookup and resume failures
Summary
After a sandbox is paused successfully, GET /cube/sandbox/info may return an incomplete sandbox representation.
When a READY pause snapshot binding exists, CubeMaster replaces the sandbox data returned by Cubelet with a newly constructed minimal SandboxData. The replacement does not preserve the original sandbox labels, template ID, annotations, resource specifications, timestamps, or volume information.
Clients that rely on sandbox labels for ownership or tenancy validation can no longer identify the paused sandbox. As a result, a subsequent connect or resume operation may fail with a 404 Not Found, even though the pause snapshot exists and CubeMaster has enough information to resume the sandbox.
There is also a related lookup issue: the CubeMaster Info path requires the live sandbox cache or proxy map before consulting the durable pause snapshot record.
Environment
- Repository:
TencentCloud/CubeSandbox - Release:
0.7.0 - Components involved:
- CubeMaster
- CubeAPI
- Cubelet
- Sandbox runtime: CubeCow pause/resume
- Pause operation completes successfully before the resume attempt
Observed behavior
The sandbox can be created and used normally:
Sandbox created: 004dd4c051d642cebd28182ea8ace0ce
Current status: running
Envd is ready.The pause request also succeeds:
Pause command sent successfully.A later connect/resume request fails:
Response 404
Resume failed: Paused sandbox 004dd4c051d642cebd28182ea8ace0ce not foundThe sandbox has not been explicitly deleted, and the pause operation returned success.
Expected behavior
After a successful pause:
GET /cube/sandbox/infoshould return the sandbox with statusPAUSED.- The response should preserve the original sandbox identity and metadata, including:
- labels
- template ID
- original annotations
- resource specifications
- creation and pause timestamps
- volume mount information
- A connect or resume request should be able to find and resume the sandbox.
- Paused sandbox discovery should not depend exclusively on live runtime caches or proxy mappings when a durable pause snapshot record exists.
Root cause analysis
1. The paused response replaces and loses the Cubelet response
In CubeMaster/pkg/service/sandbox/sandbox_info.go, SandboxInfo first retrieves sandbox data from Cubelet:
err := doget(ctx, rt.CalleeEndpoint, cubeletReq, rsp)
if err != nil {
setError(errorcode.ErrorCode_ReqCubeAPIFailed, rsp)
return
}It then calls:
if fillPauseBindingInfoFromMaster(ctx, req, rsp) {
return
}When the pause snapshot binding status is READY, fillPauseBindingInfoFromMaster creates a new minimal SandboxData:
one := &types.SandboxData{
SandboxID: req.SandboxID,
Status: st,
HostIP: proxyMap.HostIP,
SandboxIP: proxyMap.SandboxIP,
Annotations: ann,
Containers: []*types.ContainerInfo{
{
ContainerID: req.SandboxID,
Status: st,
},
},
}
rsp.Data = []*types.SandboxData{one}This overwrites the complete data previously returned by Cubelet.
The synthesized object does not include the original:
LabelsTemplateID- resource configuration
- creation timestamp
- original annotations
- volume mounts
This behavior occurs even when Cubelet successfully returned a valid paused tombstone containing the original labels.
2. CubeAPI exposes the missing labels as missing metadata
CubeAPI converts CubeMaster sandbox labels into the E2B-compatible metadata field.
Once CubeMaster replaces the original data and returns no labels, CubeAPI returns the paused sandbox with empty or missing metadata.
Any client that uses labels or metadata for resource ownership validation may then treat the paused sandbox as nonexistent.
This can result in a 404 Not Found before the actual resume request reaches CubeMaster.
3. Sandbox Info is unnecessarily coupled to live cache and proxy state
Before checking the pause snapshot binding, checkValidAndGetReq requires one of the following:
if v := localcache.GetSandboxCache(req.SandboxID); v != nil {
hostIP = v.HostIP
} else if proxyMap, ok := localcache.GetSandboxProxyMap(ctx, req.SandboxID); ok {
hostIP = proxyMap.HostIP
} else {
return setError(errorcode.ErrorCode_NotFound, rsp)
}This means that if the sandbox cache or proxy map is unavailable after pause, SandboxInfo returns NotFound without consulting the durable pause snapshot record.
However, the update/resume path already supports resolving the host from the pause snapshot record:
if rec, err := pausesnap.GetBySandbox(ctx, sandboxID); err == nil &&
rec != nil && rec.NodeIP != "" {
return rec.NodeIP, true
}Therefore, CubeMaster may have enough durable information to resume the sandbox while its Info API still reports that the sandbox does not exist.
Why this is not only a client timing issue
The CubeMaster pause implementation is synchronous.
pauseSandbox does not return success until Cubelet finishes PauseToSnapshot, performs the keep_tombstone cleanup, and CubeMaster records the pause binding as READY.
Therefore, adding an arbitrary delay before resume does not address the metadata loss. Once the binding is READY, fillPauseBindingInfoFromMaster deterministically replaces the complete Cubelet response with the incomplete synthesized response.
Suggested fix
Preserve the existing Cubelet response
When Cubelet has returned sandbox data, fillPauseBindingInfoFromMaster should update the existing object rather than replace it.
For a READY binding, it should update fields such as:
item.Status = int32(cubebox.ContainerState_CONTAINER_PAUSED)
item.Annotations[constants.CubeAnnotationPauseSnapshotID] = rec.SnapshotIDThe following fields should remain unchanged:
- labels
- template ID
- original annotations
- container image and resource fields
- creation timestamp
- volume mounts
Container status may also need to be updated to CONTAINER_PAUSED without discarding the remaining container fields.
Support a durable paused-sandbox fallback
If Cubelet data is unavailable, CubeMaster should synthesize the paused sandbox from durable data, such as:
- pause snapshot record
- persisted sandbox specification
- persisted labels and annotations
- persisted template ID
- original resource configuration
The synthesized fallback should be as complete as possible and should preserve the sandbox identity fields required by API clients.
Resolve paused sandboxes from the pause record
For requests containing SandboxID, the Info path should consult pausesnap.GetBySandbox before returning NotFound.
For a valid pause binding, CubeMaster should be able to use rec.NodeIP and rec.NodeID, similarly to the existing resume path.
A READY pause binding should be sufficient to return a paused sandbox view even if:
SandboxCacheis cold or missing- the proxy map is temporarily unavailable
- the live Cubelet runtime no longer contains a running sandbox process
Suggested test cases
- Pause a sandbox that contains custom labels and annotations.
- Query
GET /cube/sandbox/infoafter the pause binding becomesREADY. - Verify that:
- status is
PAUSED - all original labels are preserved
- template ID is preserved
- original annotations are preserved
- CPU and memory fields are preserved
- volume mounts are preserved
- status is
Additional cases:
- A
READYpause binding exists andSandboxCacheis empty. - A
READYpause binding exists and the proxy map is missing. - Cubelet returns the paused tombstone successfully.
- Cubelet returns no live sandbox, but the durable pause binding and sandbox specification exist.
- Resume succeeds using the pause record when live caches are unavailable.
- List and Info return consistent metadata for the same paused sandbox.
Impact
This issue affects integrations that use CubeSandbox labels or metadata for:
- ownership validation
- tenant isolation
- API key association
- provider or cluster association
- resource reconciliation
- filtering and listing paused sandboxes
For those integrations, a successfully paused sandbox can appear to have disappeared and cannot be resumed through the normal connect flow.
Relevant files
CubeMaster/pkg/service/sandbox/sandbox_info.goSandboxInfocheckValidAndGetReqfillPauseBindingInfoFromMaster
CubeMaster/pkg/service/sandbox/sandbox_update.go- pause/resume host resolution
CubeMaster/pkg/service/sandbox/sandbox_resume_pause.goresolvePauseHostIP
CubeAPI/src/services/sandboxes.rsfetch_sandbox_detailconnect_sandbox
CubeAPI/src/cubemaster/mod.rs- conversion from CubeMaster labels to sandbox metadata
Source: TencentCloud/CubeSandbox