Files
zeekayandHanzo Dev a386271c80 isolation is a value the org sets, and an empty one is not runc
Every sandbox was created privileged under the daemon's default runtime, and
the setting that would have changed it defaulted to an empty string that
silently meant runc. For a service whose whole premise is running code
somebody else wrote, that is not a boundary.

An org sets its isolation and the create request carries it, so a sandbox
records what it was made with: changing the policy moves new sandboxes and
leaves running ones alone. gvisor is the default. firecracker is delivered
through kata's shim, which is why it is one name rather than two. runc is
refused unless the runner names that org, and an empty list names nobody.

Absent means the default, unknown is a refusal, and a runtime the daemon does
not have is a refusal. Nothing substitutes quietly.

The runner took an organization in a field called UserId with a note beside
it saying so. Deciding who may have runc through a field named after
something else is not reviewable.

Privileged is replaced by dropping everything and granting the eight the
daemon uses. Nothing the sandbox does broke; what stopped working is mount,
mknod, raw sockets, chroot, writing to proc, and seeing the host's disks.
AUDIT_WRITE is among them because without it sudo works and complains every
time.

The creation histogram's lowest bucket was a tenth of a second, so the metric
could not observe the claim the product makes about its own speed. It can
now, and it carries the isolation, so comparing them is a query.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 13:47:31 -07:00

58 lines
1.4 KiB
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package services
import (
"context"
"github.com/hanzoai/runtime/apps/runner/pkg/cache"
"github.com/hanzoai/runtime/apps/runner/pkg/docker"
"github.com/hanzoai/runtime/apps/runner/pkg/models"
"github.com/hanzoai/runtime/apps/runner/pkg/models/enums"
)
type SandboxService struct {
cache cache.IRunnerCache
docker *docker.DockerClient
}
func NewSandboxService(cache cache.IRunnerCache, docker *docker.DockerClient) *SandboxService {
return &SandboxService{
cache: cache,
docker: docker,
}
}
func (s *SandboxService) GetSandboxStatesInfo(ctx context.Context, sandboxId string) *models.CacheData {
sandboxState, err := s.docker.DeduceSandboxState(ctx, sandboxId)
if err == nil {
s.cache.SetSandboxState(ctx, sandboxId, sandboxState)
}
data := s.cache.Get(ctx, sandboxId)
if data == nil {
return &models.CacheData{
SandboxState: enums.SandboxStateUnknown,
BackupState: enums.BackupStateNone,
DestructionTime: nil,
}
}
return data
}
func (s *SandboxService) RemoveDestroyedSandbox(ctx context.Context, sandboxId string) error {
info := s.GetSandboxStatesInfo(ctx, sandboxId)
if info != nil && info.SandboxState != enums.SandboxStateDestroyed && info.SandboxState != enums.SandboxStateDestroying {
err := s.docker.Destroy(ctx, sandboxId)
if err != nil {
return err
}
}
return nil
}