Documentation
¶
Index ¶
- Constants
- Variables
- func SecretOutboxRetryDelay(attempts int) time.Duration
- type CIDRRules
- type ClusterSecretRecord
- type ClusterSecretSealSummary
- type ContainerNetnsPoolStats
- type ContainerNetnsSlot
- type CustomDomainRow
- type DeletedSandboxView
- type EgressState
- type FirecrackerTapPoolStats
- type FirecrackerTapSlot
- type FirecrackerVMMPoolStats
- type FirecrackerVMMSlot
- type IdentityDueCursor
- type InstalledEgress
- type NetCounterDelta
- type NetCounterTotals
- type NetworkPolicyWrite
- type NodeStorageRetirement
- type PendingEgressRuleClear
- type PendingImageGCEntry
- type ProfileRef
- type QuotaSandbox
- type ResealedRow
- type ReserveHostPortResult
- type SandboxEgressProfiles
- type SandboxIdentity
- type SealedColumn
- type SealedRow
- type SecretAuditIndexChunk
- type SecretAuditIndexKey
- type SecretAuditIndexMeta
- type SecretDeleteOutboxRecord
- type SecretLifecycleStats
- type SecretPutOutboxRecord
- type SnapshotPageQuery
- type SnapshotPageRow
- type SnapshotPushCursor
- type SnapshotRegistryRetirement
- type Store
- func (s *Store) AddCustomDomain(ctx context.Context, sandboxID, hostname string, targetPort int) error
- func (s *Store) AddPendingEgressRuleClear(ctx context.Context, p PendingEgressRuleClear, clearInstalledFor string, ...) (PendingEgressRuleClear, error)
- func (s *Store) AdoptContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
- func (s *Store) AllocateFirecrackerTapSlot(ctx context.Context, sandboxID string, now time.Time) (*FirecrackerTapSlot, error)
- func (s *Store) AllocateFirecrackerVMMSlot(ctx context.Context, templateID, sandboxID string, now time.Time) (*FirecrackerVMMSlot, error)
- func (s *Store) ApplyNetCounterDeltas(ctx context.Context, deltas []NetCounterDelta) ([]NetCounterTotals, error)
- func (s *Store) ApplyPeerSecretDelete(ctx context.Context, sandboxID, incarnationID string, generation int64) error
- func (s *Store) BeginPrewarmContainerNetnsSlot(ctx context.Context, now time.Time) (*ContainerNetnsSlot, error)
- func (s *Store) BumpSecretDeleteOutboxAttempt(ctx context.Context, sandboxID, incarnationID string, generation int64) error
- func (s *Store) BumpSecretPutOutboxAttempt(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
- func (s *Store) CancelRestart(ctx context.Context, id, reason string) error
- func (s *Store) ClaimIdempotentRequest(ctx context.Context, scope, fingerprint string, now time.Time, ...) (*models.IdempotentRequestRecord, bool, error)
- func (s *Store) ClaimPooledContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
- func (s *Store) ClaimSnapshotPush(ctx context.Context, ownerRef, name string) (*models.SandboxSnapshot, time.Time, bool, error)
- func (s *Store) ClaimTemplatePush(ctx context.Context, id string) (*models.Template, time.Time, bool, error)
- func (s *Store) ClearClusterSecretTombForIncarnation(ctx context.Context, sandboxID, incarnationID string) error
- func (s *Store) ClearEgressHold(ctx context.Context, sandboxID string, now time.Time) error
- func (s *Store) ClearEgressHoldIf(ctx context.Context, sandboxID, reason string, now time.Time) (bool, error)
- func (s *Store) ClearInstalledEgress(ctx context.Context, sandboxID string, now time.Time) error
- func (s *Store) ClearNetworkQuotaExceeded(ctx context.Context, id string) error
- func (s *Store) Close() error
- func (s *Store) ClusterSecretSealGeneration(ctx context.Context, sandboxID, incarnationID string) (int64, bool, error)
- func (s *Store) ClusterSecretSealSummaries(ctx context.Context, refs []string) (map[string]ClusterSecretSealSummary, error)
- func (s *Store) ClusterSecretTombGenerationForIncarnation(ctx context.Context, sandboxID, incarnationID string) (int64, error)
- func (s *Store) CompareCloneGeneration(ctx context.Context, sandboxID, snapshotGen string) error
- func (s *Store) CompleteIdempotentRequest(ctx context.Context, scope, fingerprint, targetID string, now time.Time, ...) error
- func (s *Store) CompleteSnapshotPush(ctx context.Context, ownerRef, name string, claimedAt time.Time, ...) (bool, error)
- func (s *Store) CompleteTemplatePush(ctx context.Context, id string, claimedAt time.Time, ...) (bool, error)
- func (s *Store) CountDistinctSandboxOwners(ctx context.Context, max int) (int, error)
- func (s *Store) CountSnapshots(ctx context.Context, ownerRef string, scoped bool, sourceSandboxID string) (int, error)
- func (s *Store) CountVolumeAttachments(ctx context.Context, tenant, volumeID string) (int, error)
- func (s *Store) CountVolumes(ctx context.Context, tenant string) (int, error)
- func (s *Store) Create(ctx context.Context, sandbox *models.Sandbox) error
- func (s *Store) CreateSnapshot(ctx context.Context, snapshot *models.SandboxSnapshot) error
- func (s *Store) CreateTemplate(ctx context.Context, template *models.Template) error
- func (s *Store) CreateVolume(ctx context.Context, v *models.Volume) error
- func (s *Store) CreateWithSealedEnv(ctx context.Context, sandbox *models.Sandbox, sealedEnv []byte) error
- func (s *Store) CurrentSandboxAuditIdentity(ctx context.Context, sandboxID string) (incarnationID, ownerRef string, err error)
- func (s *Store) CurrentSandboxAuditIncarnation(ctx context.Context, sandboxID string) (string, error)
- func (s *Store) DeferSnapshotRegistryRetirement(ctx context.Context, registryRef, digest, failure string) error
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) DeleteAPIToken(ctx context.Context, id string) (removed bool, err error)
- func (s *Store) DeleteAPITokensExpiredBefore(ctx context.Context, cutoff time.Time) ([]string, error)
- func (s *Store) DeleteAllWasmCheckpointPushes(ctx context.Context, sandboxID string) error
- func (s *Store) DeleteAllWasmStateKV(ctx context.Context, sandboxID string) error
- func (s *Store) DeleteClusterSecretRowsForIncarnation(ctx context.Context, sandboxID, incarnationID string) error
- func (s *Store) DeleteClusterSecretsOriginatorWithOutbox(ctx context.Context, sandboxID, incarnationID string, recipients []string) (generation int64, err error)
- func (s *Store) DeleteEgressProfile(ctx context.Context, owner, name string) error
- func (s *Store) DeleteEnv(ctx context.Context, sandboxID string) error
- func (s *Store) DeleteExpiredDeletedSandboxViews(ctx context.Context, cutoff time.Time, limit int) (int64, error)
- func (s *Store) DeleteExpiredIdempotentRequests(ctx context.Context, now time.Time, limit int) (int64, error)
- func (s *Store) DeleteFirecrackerVMMSlot(ctx context.Context, slotID string) error
- func (s *Store) DeleteIdempotentRequest(ctx context.Context, scope, fingerprint string) error
- func (s *Store) DeleteIdentityRole(ctx context.Context, owner, tag string) error
- func (s *Store) DeleteMounts(ctx context.Context, sandboxID string) error
- func (s *Store) DeleteNodeStorageRetirement(ctx context.Context, nodeID string) (bool, error)
- func (s *Store) DeleteOrphanedWasmStateKV(ctx context.Context, limit int) (int64, error)
- func (s *Store) DeletePendingImageGC(ctx context.Context, engine, image string) error
- func (s *Store) DeletePendingImageGCIfScheduledAt(ctx context.Context, engine, image string, at time.Time) (bool, error)
- func (s *Store) DeletePendingVolumeDeletion(ctx context.Context, volumeID string) error
- func (s *Store) DeletePort(ctx context.Context, sandboxID string, port int) error
- func (s *Store) DeleteSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, generation int64) error
- func (s *Store) DeleteSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
- func (s *Store) DeleteSnapshot(ctx context.Context, ownerRef, name string) error
- func (s *Store) DeleteSnapshotAlias(ctx context.Context, alias string) error
- func (s *Store) DeleteSnapshotRegistryRetirement(ctx context.Context, registryRef, digest string) error
- func (s *Store) DeleteSnapshotRetiringRegistryCopy(ctx context.Context, ownerRef, name, pushedRef string) (retErr error)
- func (s *Store) DeleteTeamQuota(ctx context.Context, team string) error
- func (s *Store) DeleteTemplate(ctx context.Context, id string) error
- func (s *Store) DeleteVolume(ctx context.Context, tenant, id string) error
- func (s *Store) DeleteVolumeAttachmentsForSandbox(ctx context.Context, sandboxID, incarnationID string) error
- func (s *Store) DeleteVolumeIfNoAttachments(ctx context.Context, tenant, id string) error
- func (s *Store) DeleteVolumeIfUnattached(ctx context.Context, tenant, id, fallbackSource string) error
- func (s *Store) DeleteWarmPool(ctx context.Context, image string) error
- func (s *Store) DeleteWasmCheckpointPush(ctx context.Context, id int64) error
- func (s *Store) DeleteWasmModule(ctx context.Context, ownerRef, id string) error
- func (s *Store) DeleteWasmStateKV(ctx context.Context, sandboxID, key string) error
- func (s *Store) EnsureWasmCheckpointCleanupRef(ctx context.Context, sandboxID, registryRef string) (int64, error)
- func (s *Store) FinishPrewarmContainerNetnsSlot(ctx context.Context, slotID, netnsPath, containerIP string, now time.Time) error
- func (s *Store) FreeReleasingContainerNetnsSlot(ctx context.Context, slotID string, now time.Time) error
- func (s *Store) Get(ctx context.Context, id string) (*models.Sandbox, error)
- func (s *Store) GetClusterSecret(ctx context.Context, ref string) (*ClusterSecretRecord, error)
- func (s *Store) GetClusterSecretForSandboxIncarnation(ctx context.Context, sandboxID, incarnationID string) (*ClusterSecretRecord, error)
- func (s *Store) GetCompatState(ctx context.Context, sandboxID, facade string) (*models.SandboxCompatState, error)
- func (s *Store) GetContainerNetnsPoolStats(ctx context.Context) (ContainerNetnsPoolStats, error)
- func (s *Store) GetContainerNetnsSlotBySandbox(ctx context.Context, sandboxID string) (*ContainerNetnsSlot, error)
- func (s *Store) GetCreateRequestDigest(ctx context.Context, sandboxID string) (string, error)
- func (s *Store) GetDeletedSandboxView(ctx context.Context, sandboxID, facade string) (*DeletedSandboxView, error)
- func (s *Store) GetEgressProfile(ctx context.Context, owner, name string) (models.EgressProfile, error)
- func (s *Store) GetEgressState(ctx context.Context, sandboxID string) (EgressState, error)
- func (s *Store) GetEnv(ctx context.Context, sandboxID string) ([]byte, error)
- func (s *Store) GetEnvWithIdentity(ctx context.Context, sandboxID string) (blob []byte, present bool, incarnationID, ownerRef string, err error)
- func (s *Store) GetFirecrackerTapPoolStats(ctx context.Context) (FirecrackerTapPoolStats, error)
- func (s *Store) GetFirecrackerTapSlotBySandbox(ctx context.Context, sandboxID string) (*FirecrackerTapSlot, error)
- func (s *Store) GetFirecrackerVMMPoolStats(ctx context.Context, templateID string) (FirecrackerVMMPoolStats, error)
- func (s *Store) GetFirecrackerVMMSlotByID(ctx context.Context, slotID string) (*FirecrackerVMMSlot, error)
- func (s *Store) GetFirecrackerVMMSlotBySandbox(ctx context.Context, sandboxID string) (*FirecrackerVMMSlot, error)
- func (s *Store) GetIdempotentRequest(ctx context.Context, scope, fingerprint string) (*models.IdempotentRequestRecord, error)
- func (s *Store) GetIdentityRole(ctx context.Context, owner, tag string) (models.IdentityRole, error)
- func (s *Store) GetMounts(ctx context.Context, sandboxID string) ([]byte, error)
- func (s *Store) GetOrCreateVolume(ctx context.Context, v *models.Volume, maxPerTenant int) (*models.Volume, bool, error)
- func (s *Store) GetPort(ctx context.Context, sandboxID string, port int) (*models.ExposedPort, error)
- func (s *Store) GetPortByHostPort(ctx context.Context, hostPort int) (*models.ExposedPort, error)
- func (s *Store) GetSandboxAuditACLOwnerRef(ctx context.Context, sandboxID, incarnationID string) (string, error)
- func (s *Store) GetSandboxEgressProfiles(ctx context.Context, sandboxID string) (SandboxEgressProfiles, error)
- func (s *Store) GetSandboxIdentity(ctx context.Context, id string) (SandboxIdentity, error)
- func (s *Store) GetSandboxesEgressProfiles(ctx context.Context, ids []string) (map[string]SandboxEgressProfiles, error)
- func (s *Store) GetSecretAuditIndexMeta(ctx context.Context) (SecretAuditIndexMeta, bool, error)
- func (s *Store) GetSecretDeleteOutboxForIncarnation(ctx context.Context, sandboxID, incarnationID string) (*SecretDeleteOutboxRecord, error)
- func (s *Store) GetSecretPutOutboxForIncarnation(ctx context.Context, sandboxID, incarnationID string) (*SecretPutOutboxRecord, error)
- func (s *Store) GetSnapshot(ctx context.Context, ownerRef, name string) (*models.SandboxSnapshot, error)
- func (s *Store) GetSnapshotAlias(ctx context.Context, alias string) (*models.SnapshotAlias, error)
- func (s *Store) GetSnapshotByNames(ctx context.Context, ownerRef string, names []string) (*models.SandboxSnapshot, error)
- func (s *Store) GetSnapshotsByImage(ctx context.Context, images []string) ([]*models.SandboxSnapshot, error)
- func (s *Store) GetTeamQuota(ctx context.Context, team string) (models.TeamQuota, error)
- func (s *Store) GetTemplate(ctx context.Context, id string) (*models.Template, error)
- func (s *Store) GetVolume(ctx context.Context, tenant, name string) (*models.Volume, error)
- func (s *Store) GetVolumeByID(ctx context.Context, tenant, id string) (*models.Volume, error)
- func (s *Store) GetWarmPool(ctx context.Context, image string) (models.WarmPool, error)
- func (s *Store) GetWasmModule(ctx context.Context, ownerRef, id string) (WasmModuleRecord, error)
- func (s *Store) GetWasmStateKV(ctx context.Context, sandboxID, key string) ([]byte, bool, error)
- func (s *Store) HasActiveImageRef(ctx context.Context, image string) (bool, error)
- func (s *Store) HasSandbox(ctx context.Context, id string) (bool, error)
- func (s *Store) HasSandboxAuditACL(ctx context.Context, sandboxID, incarnationID string) (bool, error)
- func (s *Store) InsertAPIToken(ctx context.Context, rec identity.TokenRecord) error
- func (s *Store) InsertFirecrackerVMMSlot(ctx context.Context, slot FirecrackerVMMSlot, now time.Time) error
- func (s *Store) InsertWasmCheckpointPush(ctx context.Context, sandboxID, incarnationID, registryRef, digest string) (int64, error)
- func (s *Store) IsTemplateReferenced(ctx context.Context, id string) (bool, error)
- func (s *Store) IsTemplateReferencedByVMM(ctx context.Context, id string) (bool, error)
- func (s *Store) IsWasmDigestCatalogued(ctx context.Context, digest string) (bool, error)
- func (s *Store) IsWasmDigestCataloguedElsewhere(ctx context.Context, ownerRef, id, digest string) (bool, error)
- func (s *Store) IsWasmModuleReferenced(ctx context.Context, moduleID, moduleRef, moduleDigest string) (bool, error)
- func (s *Store) IsWasmModuleReferencedByOwner(ctx context.Context, ownerRef, moduleID, moduleRef, moduleDigest string) (bool, error)
- func (s *Store) LatestRetainedSandboxAuditIncarnation(ctx context.Context, sandboxID string) (string, error)
- func (s *Store) LatestSecretAuditIndexChunks(ctx context.Context, keys []SecretAuditIndexKey) (map[SecretAuditIndexKey]SecretAuditIndexChunk, error)
- func (s *Store) List(ctx context.Context) ([]*models.Sandbox, error)
- func (s *Store) ListAPITokens(ctx context.Context) ([]identity.TokenRecord, error)
- func (s *Store) ListAllCustomDomains(ctx context.Context) ([]CustomDomainRow, error)
- func (s *Store) ListAllExposedPorts(ctx context.Context) ([]models.ExposedPort, error)
- func (s *Store) ListAutoImportPendingIDs(ctx context.Context) ([]string, error)
- func (s *Store) ListByOwner(ctx context.Context, ownerRef string) ([]*models.Sandbox, error)
- func (s *Store) ListByRuntime(ctx context.Context, runtime string) ([]*models.Sandbox, error)
- func (s *Store) ListClusterSecretsBatch(ctx context.Context, afterRef string, limit int) ([]ClusterSecretRecord, error)
- func (s *Store) ListCompatState(ctx context.Context, facade string) (map[string]models.SandboxCompatState, error)
- func (s *Store) ListCompatStateByOwner(ctx context.Context, facade, ownerRef string) (map[string]models.SandboxCompatState, error)
- func (s *Store) ListContainerNetnsSlotsByState(ctx context.Context, state string) ([]ContainerNetnsSlot, error)
- func (s *Store) ListCustomDomains(ctx context.Context, sandboxID string) ([]models.CustomDomain, error)
- func (s *Store) ListDueSnapshotRegistryRetirements(ctx context.Context, now time.Time, limit int) ([]SnapshotRegistryRetirement, error)
- func (s *Store) ListEgressHolds(ctx context.Context) (map[string]string, error)
- func (s *Store) ListEgressProfiles(ctx context.Context, owner, after string, limit int) ([]models.EgressProfile, error)
- func (s *Store) ListFirecrackerVMMSlotsForRefill(ctx context.Context, templateID string) ([]FirecrackerVMMSlot, error)
- func (s *Store) ListGCEligibleTemplates(ctx context.Context, olderThan time.Time) ([]*models.Template, error)
- func (s *Store) ListIdempotentRequests(ctx context.Context, scope, state, afterFingerprint string, limit int) ([]*models.IdempotentRequestRecord, error)
- func (s *Store) ListIdentityRoles(ctx context.Context, owner, after string, limit int) ([]models.IdentityRole, error)
- func (s *Store) ListInstalledEgress(ctx context.Context) ([]string, error)
- func (s *Store) ListNodeStorageRetirements(ctx context.Context) ([]NodeStorageRetirement, error)
- func (s *Store) ListNonFreeContainerNetnsSlots(ctx context.Context) ([]ContainerNetnsSlot, error)
- func (s *Store) ListOrphanedWasmCheckpointPushes(ctx context.Context, limit int) ([]WasmCheckpointPushRecord, error)
- func (s *Store) ListPendingEgressRuleClears(ctx context.Context) ([]PendingEgressRuleClear, error)
- func (s *Store) ListPendingImageGCDue(ctx context.Context, cutoff time.Time, limit int) ([]PendingImageGCEntry, error)
- func (s *Store) ListPendingVolumeDeletions(ctx context.Context) ([]models.PendingVolumeDeletion, error)
- func (s *Store) ListPorts(ctx context.Context, sandboxID string) ([]models.ExposedPort, error)
- func (s *Store) ListReadyTemplateIDs(ctx context.Context) ([]string, error)
- func (s *Store) ListReadyWasmModuleRefs(ctx context.Context) ([]string, error)
- func (s *Store) ListReleasedFirecrackerVMMSlots(ctx context.Context, olderThan time.Time) ([]FirecrackerVMMSlot, error)
- func (s *Store) ListRollbackPendingIDs(ctx context.Context) ([]string, error)
- func (s *Store) ListSealedRows(ctx context.Context, col SealedColumn, afterID string, limit int) ([]SealedRow, error)
- func (s *Store) ListSecretDeleteOutboxBatch(ctx context.Context, limit int) ([]SecretDeleteOutboxRecord, error)
- func (s *Store) ListSecretDeleteOutboxDue(ctx context.Context, now time.Time, limit int) ([]SecretDeleteOutboxRecord, error)
- func (s *Store) ListSecretPutOutboxBatch(ctx context.Context, limit int) ([]SecretPutOutboxRecord, error)
- func (s *Store) ListSecretPutOutboxDue(ctx context.Context, now time.Time, limit int) ([]SecretPutOutboxRecord, error)
- func (s *Store) ListSnapshotAliases(ctx context.Context, facade string) (map[string]models.SnapshotAlias, error)
- func (s *Store) ListSnapshotAliasesForOwner(ctx context.Context, facade, ownerRef string) (map[string]models.SnapshotAlias, error)
- func (s *Store) ListSnapshotPage(ctx context.Context, q SnapshotPageQuery) ([]SnapshotPageRow, error)
- func (s *Store) ListSnapshots(ctx context.Context) ([]*models.SandboxSnapshot, error)
- func (s *Store) ListSnapshotsPendingPushPage(ctx context.Context, after SnapshotPushCursor, limit int) ([]*models.SandboxSnapshot, error)
- func (s *Store) ListTeamQuotas(ctx context.Context) ([]models.TeamQuota, error)
- func (s *Store) ListTemplateInventoryIDs(ctx context.Context) (readyIDs, catalogIDs []string, err error)
- func (s *Store) ListTemplates(ctx context.Context) ([]*models.Template, error)
- func (s *Store) ListTemplatesPendingPush(ctx context.Context) ([]*models.Template, error)
- func (s *Store) ListTemplatesReadyBefore(ctx context.Context, cutoff time.Time) ([]*models.Template, error)
- func (s *Store) ListUnhealthyTemplates(ctx context.Context) ([]*models.Template, error)
- func (s *Store) ListVolumeAttachmentsForSandbox(ctx context.Context, sandboxID string) ([]models.VolumeAttachment, error)
- func (s *Store) ListVolumes(ctx context.Context, tenant string) ([]models.Volume, error)
- func (s *Store) ListWarmPools(ctx context.Context) ([]models.WarmPool, error)
- func (s *Store) ListWasmCheckpointPushes(ctx context.Context, sandboxID string) ([]WasmCheckpointPushRecord, error)
- func (s *Store) ListWasmCheckpointPushesForIncarnation(ctx context.Context, sandboxID, incarnationID string) ([]WasmCheckpointPushRecord, error)
- func (s *Store) ListWasmModules(ctx context.Context) ([]WasmModuleRecord, error)
- func (s *Store) ListWasmModulesOlderThan(ctx context.Context, cutoff time.Time) ([]WasmModuleRecord, error)
- func (s *Store) ListWasmStateKVKeys(ctx context.Context, sandboxID string) ([]string, error)
- func (s *Store) LiveVolumeExistsForSource(ctx context.Context, source string) (bool, error)
- func (s *Store) MarkContainerNetnsSlotRealized(ctx context.Context, sandboxID, netnsPath, containerIP string, now time.Time) (*ContainerNetnsSlot, error)
- func (s *Store) MarkContainerNetnsSlotReleasing(ctx context.Context, slotID, owner, netnsPath, containerIP string, ...) error
- func (s *Store) MarkFirecrackerVMMSlotFailed(ctx context.Context, slotID, errMsg string, now time.Time) error
- func (s *Store) MarkFirecrackerVMMSlotLoaded(ctx context.Context, slotID, apiSocket, runDir string, vsockCID uint32, ...) error
- func (s *Store) MarkNetworkQuotaExceeded(ctx context.Context, id string, detectedAt time.Time) error
- func (s *Store) MarkRestarted(ctx context.Context, id string, at time.Time) error
- func (s *Store) MarkSandboxRollbackPending(ctx context.Context, id string) error
- func (s *Store) MarkSecretDeleteOutboxPromoted(ctx context.Context, sandboxID, incarnationID string, generation int64) (promoted bool, err error)
- func (s *Store) MarkTemplatePushPending(ctx context.Context, id string) (bool, error)
- func (s *Store) MarkTemplateUnhealthy(ctx context.Context, id, reason string) (bool, error)
- func (s *Store) NextClusterSecretSealGenerationForIncarnation(ctx context.Context, sandboxID, incarnationID string) (int64, error)
- func (s *Store) ProfileReferences(ctx context.Context) ([]ProfileRef, error)
- func (s *Store) PruneClusterSecretTombs(ctx context.Context, cutoff time.Time, limit int) (int64, error)
- func (s *Store) PruneSandboxAuditACL(ctx context.Context, cutoff time.Time) (int64, error)
- func (s *Store) PutClusterSecret(ctx context.Context, rec ClusterSecretRecord) (int64, error)
- func (s *Store) PutDeletedSandboxView(ctx context.Context, sandboxID, facade, ownerRef, viewJSON string, ...) error
- func (s *Store) PutEgressProfile(ctx context.Context, owner, name string, allowOut []string, description string, ...) (p models.EgressProfile, changed bool, err error)
- func (s *Store) PutEnv(ctx context.Context, sandboxID string, sealed []byte) error
- func (s *Store) PutIdentityRole(ctx context.Context, owner, tag, minRole string, now time.Time) (models.IdentityRole, bool, error)
- func (s *Store) PutMounts(ctx context.Context, sandboxID string, sealed []byte) error
- func (s *Store) PutNodeStorageRetirement(ctx context.Context, nodeID, actor, reason string, attestedAt time.Time) error
- func (s *Store) PutSandboxIdentity(ctx context.Context, row SandboxIdentity) error
- func (s *Store) PutTeamQuota(ctx context.Context, team string, limits models.TeamQuotaRequest, ...) (q models.TeamQuota, changed bool, err error)
- func (s *Store) PutVolumeAttachments(ctx context.Context, attachments []models.VolumeAttachment) error
- func (s *Store) PutWarmPool(ctx context.Context, in models.WarmPool, now time.Time) (p models.WarmPool, changed bool, err error)
- func (s *Store) PutWasmStateKV(ctx context.Context, sandboxID, key string, value []byte) error
- func (s *Store) ReadIdentityKeys(ctx context.Context) (cloudidentity.KeySet, error)
- func (s *Store) ReadSecretAuditIndex(ctx context.Context, key SecretAuditIndexKey, minTime int64) (SecretAuditIndexMeta, []SecretAuditIndexChunk, bool, error)
- func (s *Store) ReassignContainerNetnsSandbox(ctx context.Context, fromSandboxID, toSandboxID string, now time.Time) error
- func (s *Store) RecordIdentityTokenFailed(ctx context.Context, id, reason string) error
- func (s *Store) RecordIdentityTokenPushed(ctx context.Context, id, kid string, expires time.Time) error
- func (s *Store) RecordProgramExit(ctx context.Context, id string, runGeneration int64, at time.Time, ...) (bool, error)
- func (s *Store) RefreshPendingImageGCIfExists(ctx context.Context, image string, at time.Time) (bool, error)
- func (s *Store) ReleaseContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) error
- func (s *Store) ReleaseFirecrackerTapSlot(ctx context.Context, sandboxID string) error
- func (s *Store) ReleaseFirecrackerVMMSlot(ctx context.Context, sandboxID string, now time.Time) error
- func (s *Store) ReleaseOrphanedFirecrackerVMMSlots(ctx context.Context, now time.Time) (int, error)
- func (s *Store) ReleaseSnapshotPush(ctx context.Context, ownerRef, name string, claimedAt time.Time, ...) (bool, error)
- func (s *Store) ReleaseTemplatePush(ctx context.Context, id string, claimedAt time.Time, state, errMsg string) (bool, error)
- func (s *Store) RemoveCustomDomain(ctx context.Context, sandboxID, hostname string) error
- func (s *Store) ResealSealedRows(ctx context.Context, col SealedColumn, rows []ResealedRow) (written []bool, err error)
- func (s *Store) ReserveContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
- func (s *Store) ResetContainerNetnsSlotToFree(ctx context.Context, slotID string, now time.Time) error
- func (s *Store) ResetSecretAuditIndex(ctx context.Context, meta SecretAuditIndexMeta) error
- func (s *Store) ResolveCustomDomain(ctx context.Context, hostname string) (string, error)
- func (s *Store) ResolveSandboxIDByName(ctx context.Context, ownerRef, name string) (string, error)
- func (s *Store) ResolveWasmModule(ctx context.Context, ownerRef, id string) (WasmModuleRecord, error)
- func (s *Store) RetireClusterSecretGeneration(ctx context.Context, sandboxID, incarnationID string, generation int64) error
- func (s *Store) RevokeSandboxTokens(ctx context.Context, id string, notBefore int64) (int64, error)
- func (s *Store) RewrapClusterSecret(ctx context.Context, ref string, generation int64, old, rewrapped []byte) (bool, error)
- func (s *Store) RollbackSandboxCreate(ctx context.Context, id, incarnationID string) error
- func (s *Store) SandboxAuditIncarnations(ctx context.Context, ids []string) (map[string]string, error)
- func (s *Store) SandboxIDsClaimingContainerIP(ctx context.Context, ip string) ([]string, error)
- func (s *Store) SandboxIdentitiesDue(ctx context.Context, cutoff time.Time, after IdentityDueCursor, limit int) ([]SandboxIdentity, error)
- func (s *Store) SandboxesReferencingProfile(ctx context.Context, owner, name string) ([]ProfileRef, error)
- func (s *Store) SchedulePendingImageGC(ctx context.Context, engine, image string, at time.Time) error
- func (s *Store) SchedulePendingVolumeDeletion(ctx context.Context, v models.Volume, source string) error
- func (s *Store) ScheduleRestart(ctx context.Context, id string, failures int, at time.Time) error
- func (s *Store) ScheduleSnapshotRegistryRetirement(ctx context.Context, r SnapshotRegistryRetirement) error
- func (s *Store) SecretAuditIndexStats(ctx context.Context) (chunks, entries int64, err error)
- func (s *Store) SecretDeleteOwedByRecipient(ctx context.Context) (map[string]int, error)
- func (s *Store) SecretLifecycleStats(ctx context.Context) (SecretLifecycleStats, error)
- func (s *Store) SeedContainerNetnsSlot(ctx context.Context, slotID string, now time.Time) error
- func (s *Store) SeedFirecrackerTapSlot(ctx context.Context, slot FirecrackerTapSlot, now time.Time) error
- func (s *Store) SetAllowPublicTraffic(ctx context.Context, id string, allow bool, publicURL string) error
- func (s *Store) SetAutoImportPending(ctx context.Context, id string, pending bool) error
- func (s *Store) SetCustomDomainStatus(ctx context.Context, hostname string, status models.CustomDomainStatus, ...) error
- func (s *Store) SetEgressHold(ctx context.Context, sandboxID, reason string, now time.Time) error
- func (s *Store) SetEgressHoldRanked(ctx context.Context, sandboxID, reason string, rank map[string]int, ...) error
- func (s *Store) SetEgressProfilesApplied(ctx context.Context, id string, applied []models.EgressProfileRef) error
- func (s *Store) SetFleetSuspended(ctx context.Context, id string, suspended bool) error
- func (s *Store) SetIdempotentRequestTarget(ctx context.Context, scope, fingerprint, targetID string, now time.Time) error
- func (s *Store) SetInstalledEgress(ctx context.Context, sandboxID string, inst InstalledEgress, now time.Time) error
- func (s *Store) SetNetworkLimits(ctx context.Context, id string, bytesInLimit, bytesOutLimit int64) error
- func (s *Store) SetPendingEgressRuleClear(ctx context.Context, p PendingEgressRuleClear, now time.Time) error
- func (s *Store) SetSandboxEgressProfiles(ctx context.Context, id string, p NetworkPolicyWrite) error
- func (s *Store) SetSecretCipher(cipher *secrets.Cipher)
- func (s *Store) SetStatusReason(ctx context.Context, id, reason string, exitCode *int) error
- func (s *Store) SetStatusReasonIfStatus(ctx context.Context, id string, status models.SandboxStatus, reason string, ...) (bool, error)
- func (s *Store) SetWakeArmed(ctx context.Context, id string, armed bool) error
- func (s *Store) ShiftSecretAuditIndex(ctx context.Context, floor, delta int64, meta SecretAuditIndexMeta) error
- func (s *Store) SnapshotRegistryCopyInUse(ctx context.Context, registryRef, digest, ownerRef, name string) (inUse, pushPending bool, err error)
- func (s *Store) TeamQuotaSandboxes(ctx context.Context, ownerRef string) ([]QuotaSandbox, error)
- func (s *Store) Touch(ctx context.Context, id string, at time.Time) error
- func (s *Store) TouchSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, generation int64) error
- func (s *Store) TouchSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
- func (s *Store) TransferFirecrackerTapSlot(ctx context.Context, fromID, toID string, now time.Time) (*FirecrackerTapSlot, error)
- func (s *Store) TryReserveHostPort(ctx context.Context, sandboxID string, containerPort, hostPort int, ...) (ReserveHostPortResult, error)
- func (s *Store) UpdateLifecycle(ctx context.Context, id string, l models.Lifecycle) error
- func (s *Store) UpdateRuntime(ctx context.Context, id, containerID, containerIP, publicURL string) error
- func (s *Store) UpdateSecretDeleteOutboxRecipients(ctx context.Context, sandboxID, incarnationID string, recipients []string, ...) error
- func (s *Store) UpdateSecretPutOutboxRecipients(ctx context.Context, sandboxID, incarnationID string, recipients []string, ...) error
- func (s *Store) UpdateStatus(ctx context.Context, id string, status models.SandboxStatus, lastError string) error
- func (s *Store) UpdateStatusWithReason(ctx context.Context, id string, status models.SandboxStatus, ...) error
- func (s *Store) UpdateTags(ctx context.Context, id string, tags map[string]string) error
- func (s *Store) UpdateTemplateSnapshotFailed(ctx context.Context, id, snapshotError string) error
- func (s *Store) UpdateTemplateSnapshotReady(ctx context.Context, id, memPath, statePath string, sizeBytes int64, ...) error
- func (s *Store) UpdateTemplateStatus(ctx context.Context, id string, status models.TemplateStatus, ...) error
- func (s *Store) UpdateWasmCheckpoint(ctx context.Context, ...) error
- func (s *Store) UpdateWasmRegistryPush(ctx context.Context, sandboxID, incarnationID, registryRef, digest string) (applied bool, err error)
- func (s *Store) Upsert(ctx context.Context, sandbox *models.Sandbox) error
- func (s *Store) UpsertAccountMapping(ctx context.Context, ownerRef, externalID string) error
- func (s *Store) UpsertCompatState(ctx context.Context, sandboxID, facade, stateJSON string) error
- func (s *Store) UpsertPort(ctx context.Context, exposure models.ExposedPort) error
- func (s *Store) UpsertSandboxAuditACL(ctx context.Context, sandboxID, ownerRef, incarnationID string) error
- func (s *Store) UpsertSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, recipients []string, ...) error
- func (s *Store) UpsertSecretDeleteOutboxCopiedAt(ctx context.Context, sandboxID, incarnationID string, recipients []string, ...) error
- func (s *Store) UpsertSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64, ...) error
- func (s *Store) UpsertSnapshotAlias(ctx context.Context, alias models.SnapshotAlias) error
- func (s *Store) UpsertWasmModule(ctx context.Context, rec WasmModuleRecord) error
- func (s *Store) WasmCheckpointRefInUse(ctx context.Context, sandboxID string, excludePushID int64, ...) (bool, error)
- func (s *Store) WasmDigestsInUse(ctx context.Context, digests []string) (map[string]struct{}, error)
- func (s *Store) WriteIdentityKeys(ctx context.Context, expected int64, keys []cloudidentity.KeyRecord) (cloudidentity.KeySet, error)
- func (s *Store) WriteNetworkPolicy(ctx context.Context, id string, p NetworkPolicyWrite) error
- func (s *Store) WriteSecretAuditIndex(ctx context.Context, expect, meta SecretAuditIndexMeta, ...) error
- type WasmCheckpointPushRecord
- type WasmModuleRecord
Constants ¶
const ( NetnsSlotStateFree = "free" NetnsSlotStateReserved = "reserved" NetnsSlotStateRealized = "realized" NetnsSlotStatePooled = "pooled" NetnsSlotStateAdopted = "adopted" // NetnsSlotStateReleasing holds a slot whose host teardown (CNI DEL, NAT // chain, netns delete) failed. The row has no owner, so no sandbox can find // or claim it, but it keeps netns_path + container_ip: they are the // identity the retry needs to delete exactly what CNI ADD created. Freeing // such a slot instead would hand a new sandbox a slot whose lease and // masquerade chain still exist (host-local then refuses the slot's next // ADD as a duplicate, and the leftover rules pile up). NetnsSlotStateReleasing = "releasing" )
Container netns pool lifecycle states. Stored as TEXT; queries use literals.
const ( SecretOutboxBackoffBase = 30 * time.Second SecretOutboxBackoffCap = 15 * time.Minute )
Retry schedule for durable peer obligations (both outboxes). Attempt n is due min(SecretOutboxBackoffBase·2^(n-1), SecretOutboxBackoffCap) after the last attempt (updated_at); a row never attempted is due at once. Before this, attempts was counted and never read: a permanently unreachable recipient was retried every tick forever. The schedule lives in the query, not in a Go-side skip, because a backlog of backed-off rows — every obligation to a decommissioned node — would otherwise occupy the whole oldest-first batch and starve fresh work until its backoff expired.
const ( FirecrackerVMMSlotStatusSpawning = "spawning" FirecrackerVMMSlotStatusLoaded = "loaded" FirecrackerVMMSlotStatusAllocated = "allocated" FirecrackerVMMSlotStatusReleased = "released" )
Firecracker warm-VMM pool status constants. Kept as bare strings rather than a typed enum because SQLite stores them as TEXT and the store-layer queries WHERE status='...' literals — a typed wrapper would just force every call site to string()-coerce. The state machine is documented inline in the CREATE TABLE statement above.
const PushClaimLease = 30 * time.Minute
PushClaimLease bounds how long a row may sit in 'pushing' before another reconciler tick may reclaim it. Longer than any realistic single artifact push, short enough that a crashed daemon's claims drain on the next few ticks rather than needing operator action. The reconcilers also cap each push at this long, so a push never outlives the claim it ran under.
Variables ¶
var ( // ErrAPITokenNameTaken is a create whose name another token in the same // team already holds (409). ErrAPITokenNameTaken = errors.New("API token name already used in this team") // ErrAPITokenIDTaken is a create whose random id collides with an // existing token's: the caller mints a new id and retries. ErrAPITokenIDTaken = errors.New("API token id already exists") )
var ( // ErrIdentityKeysConflict is a key-set write whose expected generation // is no longer current: another writer got there first. Re-read and // decide again. ErrIdentityKeysConflict = errors.New("identity signing keys changed concurrently") // ErrIdentityRoleNotFound is a role tag not on the owner's allow list. ErrIdentityRoleNotFound = errors.New("identity role tag not found") )
var ErrClusterSecretDeleteGenerationTooNew = errors.New("cluster secret delete generation exceeds local high-water mark")
ErrClusterSecretDeleteGenerationTooNew rejects a peer DELETE that attempts to jump beyond the local lifecycle high-water mark by more than one. This prevents a wire-supplied generation from permanently fencing legitimate reseals (and avoids poisoning the next-generation counter).
var ErrClusterSecretGenerationExhausted = errors.New("cluster secret generation exhausted")
ErrClusterSecretGenerationExhausted is returned instead of overflowing the signed generation counter after an imported/corrupt max-int high-water mark.
var ErrClusterSecretPayloadConflict = errors.New("cluster secret payload conflict")
ErrClusterSecretPayloadConflict is returned when a PUT repeats an existing seal_generation with a different ciphertext (forked seal).
var ErrClusterSecretStaleGeneration = errors.New("cluster secret stale generation")
ErrClusterSecretStaleGeneration is returned when a peer/originator PUT carries a seal_generation strictly older than a row already stored for the same ref or sandbox. Peers must map this to a non-2xx response so Push does not ACK.
var ErrClusterSecretTombBlocksPut = errors.New("cluster secret tomb blocks put")
ErrClusterSecretTombBlocksPut is returned when a peer/originator PUT carries seal_generation <= an active delete tomb generation.
var ErrCustomDomainConflict = errors.New("custom domain hostname already taken")
ErrCustomDomainConflict is returned by AddCustomDomain when the hostname is already owned by a different sandbox. Surfaced through the API as 409. Same hostname for the same sandbox is idempotent (not a conflict) — that lets retries and reconcile re-converge without surfacing spurious errors.
var ErrCustomDomainPortMismatch = errors.New("custom domain target_port mismatch on re-add")
ErrCustomDomainPortMismatch surfaces an idempotent re-add of an already-attached hostname that carries a different target_port than the stored row. We never silently change the dial target — that would redirect live traffic without the caller knowing. The service layer translates this to HTTP 409 so the caller can detach + re-add deliberately.
var ErrEgressProfileInUse = errors.New("egress profile is referenced by sandboxes")
ErrEgressProfileInUse means a live sandbox still references the profile, so it can't be deleted (409).
var ErrEgressProfileNotFound = errors.New("egress profile not found")
ErrEgressProfileNotFound means no profile of that name exists for the owner.
var ErrJSBundleInUse = errors.New("js bundle is referenced by an active sandbox")
ErrJSBundleInUse blocks DELETE /v1/js-bundles/{digest} while an isolate sandbox still pins that bundle digest (plans/isolate-runtime.md §8).
var ErrNoFreeContainerNetnsSlot error = capacity.NewSlotPoolExhausted("container netns pool")
ErrNoFreeContainerNetnsSlot is returned when the netns pool is exhausted. It is a capacity refusal (errors.Is matches capacity.ErrCapacityExceeded), so the API answers 503 + Retry-After and placement can try another node, instead of the catch-all 400 a full node used to look like.
var ErrNoFreeFirecrackerTapSlot error = capacity.NewSlotPoolExhausted("firecracker tap pool")
ErrNoFreeFirecrackerTapSlot is returned by AllocateFirecrackerTapSlot when every slot is claimed. It is a capacity refusal (errors.Is matches capacity.ErrCapacityExceeded), so a full pool answers 503 + Retry-After like any other admission refusal rather than a catch-all 400.
var ErrNoFreeFirecrackerVMMSlot = errors.New("firecracker vmm pool: no loaded slot")
ErrNoFreeFirecrackerVMMSlot is returned by AllocateFirecrackerVMMSlot when no 'loaded' slot exists for the requested template. PR 4-B's caller treats this as the cold-spawn fallback signal, not an error state — the pool being momentarily empty is the expected behavior under load between spawn-and-load passes.
var ErrNoPooledContainerNetnsSlot = errors.New("container netns pool: no pooled slot")
ErrNoPooledContainerNetnsSlot means no prewarmed slot is available for claim.
var ErrNotFound = errors.New("sandbox not found")
var ErrSandboxNameConflict = errors.New("sandbox name already in use")
ErrSandboxNameConflict is returned by Create/Upsert when the sandbox's name collides with another row of the same owner, or with an existing id. Names are unique per owner_ref (idx_sandboxes_name); empty names skip the name uniqueness check but ids still cannot collide with existing non-empty names.
var ErrSecretAuditIndexStale = errors.New("secret audit index moved underneath this write")
ErrSecretAuditIndexStale is returned when a write's expected meta no longer matches the stored one: another writer (rebuild, prune shift) moved the index first, and the caller's entries were computed against the old state.
var ErrSnapshotNameConflict = errors.New("snapshot name already in use")
var ErrTemplateIDConflict = errors.New("template id already in use")
ErrTemplateIDConflict is returned by CreateTemplate when a row with the caller-supplied ID already exists. Operators that retry POST /v1/templates with an explicit id get a 409 instead of a 500 — the standard idempotency shape the v1 API uses everywhere else.
var ErrTemplateInUse = errors.New("template is referenced by an active sandbox")
ErrTemplateInUse is the service-layer sentinel for "cannot delete: an active sandbox still names this template_id". DeleteTemplate returns it after IsTemplateReferenced returns true; the API translates it to 409. Held in the store package only because the SQL probe lives here.
var ErrVolumeExists = errors.New("volume already exists for this tenant")
ErrVolumeExists is returned by CreateVolume when the (tenant, name) pair is already taken. Facades map this to 409 Conflict. It is distinct from a generic constraint error so callers can branch on it for idempotent get-or-create semantics.
var ErrVolumeInUse = errors.New("volume is still attached")
ErrVolumeInUse is returned by DeleteVolumeIfUnattached when indexed attachments still reference the volume.
var ErrVolumeQuotaExceeded = errors.New("tenant volume quota exceeded")
ErrVolumeQuotaExceeded is returned by GetOrCreateVolume when inserting a new row would exceed the tenant's configured volume-count cap. Existing rows are returned idempotently and do not consume quota again.
var ErrWarmPoolLimit = fmt.Errorf("at most %d warm pools may be configured", models.MaxWarmPools)
ErrWarmPoolLimit is a PUT of a new entry when models.MaxWarmPools are already stored (409).
var ErrWarmPoolNotFound = errors.New("warm pool not found")
ErrWarmPoolNotFound means no warm-pool entry names that image (404).
var ErrWasmModuleIDConflict = errors.New("wasm module id already in use")
ErrWasmModuleIDConflict is returned when POST /v1/wasm-modules reuses an id bound to a different module_ref.
var ErrWasmModuleInUse = errors.New("wasm module is referenced by an active sandbox")
ErrWasmModuleInUse blocks DELETE while a sandbox still references the module.
var SealedColumns = []SealedColumn{SealedToolboxToken, SealedRegistryAuth, SealedMounts, SealedEnv}
SealedColumns is every server-key-sealed column in the store. The egress CA record (a file) and local cluster-secret copies (envelopes) are resealed by the service.
Functions ¶
func SecretOutboxRetryDelay ¶ added in v0.6.1
SecretOutboxRetryDelay is how long a row with the given attempt count waits after its last attempt before it is due again.
Types ¶
type CIDRRules ¶ added in v0.6.6
type CIDRRules struct {
Allow []string `json:"allow,omitempty"`
Deny []string `json:"deny,omitempty"`
}
CIDRRules is one CIDR rule set, as ApplyEgressPolicy installs it.
type ClusterSecretRecord ¶ added in v0.2.1
type ClusterSecretRecord struct {
Ref string
SandboxID string
Version int
Recipients []string
SealedPayload []byte
SealGeneration int64
CreatedAt time.Time
UpdatedAt time.Time
// PutOutboxIncarnationID + PutOutboxRecipients journal remaining peer PUTs
// in the same transaction as the sealed row when PutOutboxRecipients != nil.
PutOutboxIncarnationID string
PutOutboxRecipients *[]string
// RetireRecipients stages peer deletion atomically with a resealed row.
// Reconciliation waits for Raft to publish SealGeneration first.
RetireRecipients *[]string
}
ClusterSecretRecord is an opaque cluster-secret payload addressed by ref. The store never decrypts SealedPayload; service owns the envelope format.
type ClusterSecretSealSummary ¶ added in v0.6.1
ClusterSecretSealSummary is what failover readiness needs from a sealed row: which generation this node holds and who the recipients are. The encrypted payload is never loaded for it.
type ContainerNetnsPoolStats ¶ added in v0.5.6
type ContainerNetnsPoolStats struct {
Total int
Free int
Reserved int
Realized int
Pooled int
Adopted int
// Releasing counts slots parked after a failed host teardown. A count that
// stays above zero means CNI DEL keeps failing on this node.
Releasing int
}
ContainerNetnsPoolStats reports pool occupancy.
type ContainerNetnsSlot ¶ added in v0.5.6
type ContainerNetnsSlot struct {
SlotID string
NetnsPath string
ContainerIP string
SandboxID string
State string
CreatedAt time.Time
UpdatedAt time.Time
}
ContainerNetnsSlot is one row of container_netns_slots.
type CustomDomainRow ¶ added in v0.3.1
type CustomDomainRow struct {
Hostname string
SandboxID string
Status models.CustomDomainStatus
LastError string
TargetPort int
CreatedAt time.Time
UpdatedAt time.Time
}
CustomDomainRow is the per-row representation read out of sandbox_custom_domains. ListAllCustomDomains returns these so the reconcile loop and the cluster FSM hydration can walk the full set.
type DeletedSandboxView ¶ added in v0.6.7
type DeletedSandboxView struct {
SandboxID string
Facade string
OwnerRef string
ViewJSON string
CreatedAt time.Time
}
DeletedSandboxView is one durable tombstone row: the terminal body a facade should replay for a sandbox that no longer exists, plus the owner that may see it and the time it was recorded (for the replay-window sweep).
type EgressState ¶ added in v0.6.6
type EgressState struct {
SandboxID string
HoldReason string
HoldSince time.Time
// InspectCA: the sandbox was created trusting the node's CA (P3-1).
InspectCA bool
// Withheld are the env keys the sandbox holds placeholders for (P3-2).
Withheld []string
// Installed is the host enforcement that may be in place for the
// sandbox; nil when it is what the stored policy installs.
Installed *InstalledEgress
}
EgressState is a sandbox's egress-gateway state (sandbox_egress).
type FirecrackerTapPoolStats ¶ added in v0.4.1
FirecrackerTapPoolStats reports the current pool occupancy. Used by /healthz and the admission controller — a near-empty pool blocks new Firecracker creates upstream of the failing Allocate call, which is a better operator experience than discovering the exhaustion on the next user request.
type FirecrackerTapSlot ¶ added in v0.4.1
type FirecrackerTapSlot struct {
TapName string
CIDR string
HostIP string
GuestIP string
VsockCID uint32
SandboxID string
CreatedAt time.Time
AllocatedAt time.Time
}
FirecrackerTapSlot is one pre-seeded row of the firecracker_tap_pool. Mirrors the table shape. SandboxID is empty when the slot is free, set to the owning sandbox when allocated; AllocatedAt is the zero time when free.
type FirecrackerVMMPoolStats ¶ added in v0.4.1
type FirecrackerVMMPoolStats struct {
Total int
Spawning int
Loaded int
Allocated int
Released int
}
FirecrackerVMMPoolStats is the per-template breakdown by status used by /healthz and PR 4-B's refill goroutine to decide how many new slots to spawn. Total is the count of all non-deleted rows for the template; the sum of the per-status counters equals Total.
type FirecrackerVMMSlot ¶ added in v0.4.1
type FirecrackerVMMSlot struct {
ID string
TemplateID string
Status string
SandboxID string
APISocket string
RunDir string
VsockCID uint32
CreatedAt time.Time
LoadedAt time.Time
AllocatedAt time.Time
ReleasedAt time.Time
LastError string
}
FirecrackerVMMSlot is one row of firecracker_vmm_pool. Mirrors the table shape; nullable DATETIME columns map to zero-valued time.Time when absent so the policy wrapper (internal/pool/vmm) doesn't have to plumb sql.NullTime through its API.
type IdentityDueCursor ¶ added in v0.6.12
IdentityDueCursor is where a page of SandboxIdentitiesDue left off: the last row's expiry and id. The zero cursor starts at the beginning.
func (IdentityDueCursor) Next ¶ added in v0.6.12
func (c IdentityDueCursor) Next(page []SandboxIdentity) IdentityDueCursor
Next is the cursor after the last row of page.
type InstalledEgress ¶ added in v0.6.6
type InstalledEgress struct {
Gateway bool `json:"gateway,omitempty"`
CIDR []CIDRRules `json:"cidr,omitempty"`
}
InstalledEgress is the host enforcement that may be in place for a container sandbox: whether a gateway attachment may exist, and which CIDR rule sets may be installed. It is written before a policy transition changes the stored policy and cleared once the transition has applied, so a record exists exactly while a transition is unfinished (a failure, a crash): it is then a superset (the old enforcement and the new), the next transition tears down everything a partial apply left behind, and recovery finds it (ListInstalledEgress).
type NetCounterDelta ¶ added in v0.6.12
NetCounterDelta is one sandbox's byte counts since the previous netstats poll. Both are non-negative.
type NetCounterTotals ¶ added in v0.6.12
type NetCounterTotals struct {
Index int
SandboxID string
OwnerRef string
BytesIn int64
BytesOut int64
BytesInLimit int64
BytesOutLimit int64
QuotaExceeded bool
}
NetCounterTotals is a sandbox's cumulative counters, caps and quota flag as they stand right after a delta, read by the same statement that applied it. Index is that delta's position in the ApplyNetCounterDeltas input, so a caller can pair totals with its own per-delta data even when one sandbox appears twice.
type NetworkPolicyWrite ¶ added in v0.6.6
type NetworkPolicyWrite struct {
BlockAll bool
AllowOut []string
DenyOut []string
Inline []string
Profiles []string
OwnerRef string
// Mode is the egress mode, "learn" or "" (enforce).
Mode string
// Rules are the method and path rules (P3-1); InspectCA marks a sandbox
// created trusting the node's CA, and is never cleared.
Rules []models.EgressRule
InspectCA bool
// Withheld are the env keys the create replaced with placeholders
// (P3-2); empty leaves the recorded set alone.
Withheld []string
}
NetworkPolicyWrite is a sandbox's whole egress policy as stored. AllowOut is the effective list (inline plus every profile's), which is what enforcement reads from the sandboxes row; Inline and Profiles are kept beside it for GET and policy replays.
type NodeStorageRetirement ¶ added in v0.6.1
type NodeStorageRetirement struct {
NodeID string
AttestedAt time.Time
Actor string
Reason string
CreatedAt time.Time
}
NodeStorageRetirement is an operator's attestation that a node's storage was destroyed. It is the only thing besides an authenticated ACK that may discharge a deletion obligation owed to that node.
type PendingEgressRuleClear ¶ added in v0.6.6
type PendingEgressRuleClear struct {
Scope string
IP string
SandboxID string
Rules []CIDRRules
Hold bool
CreatedAt time.Time
UpdatedAt time.Time
}
PendingEgressRuleClear is the host egress rules that may still be installed at one IP of one rule scope (an engine's firewall) with no sandbox's enforcement accounting for them: the CIDR rule sets, and whether a hold DROP may be there. SandboxID is the last sandbox that left them, for logs only.
func (PendingEgressRuleClear) Empty ¶ added in v0.6.6
func (p PendingEgressRuleClear) Empty() bool
Empty reports whether nothing is left to clear.
type PendingImageGCEntry ¶ added in v0.3.1
type PendingImageGCEntry struct {
// Engine is the container engine holding this copy of the image. Empty
// on rows written before the ledger became engine-aware; the janitor
// resolves that to the host's configured engine.
Engine string
Image string
ScheduledAt time.Time
}
PendingImageGCEntry is one row from the pending_image_gc ledger. scheduled_at travels with the image so the janitor can pin its remove/delete decision to the exact row it observed — see DeletePendingImageGCIfScheduledAt for the refresh-race rationale.
type ProfileRef ¶ added in v0.6.6
ProfileRef is one sandbox's reference to a profile, with the generation of it that is live on the sandbox (0 until the first apply).
type QuotaSandbox ¶ added in v0.6.12
QuotaSandbox is one sandbox as a team quota counts it.
type ResealedRow ¶ added in v0.6.9
ResealedRow is a value resealed under the current key, to write only if the stored bytes are still Old.
type ReserveHostPortResult ¶ added in v0.1.4
type ReserveHostPortResult struct {
Reserved bool
Existing *models.ExposedPort
}
ReserveHostPortResult is the three-state outcome of TryReserveHostPort. Exactly one of Reserved/Existing/(neither) is set:
- Reserved: the row was inserted; the candidate host port is now ours.
- Existing != nil: a row for (sandbox_id, port) already exists. The allocator MUST stop walking the pool — no other host_port will satisfy the (sandbox_id, port) primary key. Caller decides whether to reuse the existing exposure or surface an error.
- both zero: the partial unique index on host_port rejected this candidate (some other sandbox owns it). Caller may retry.
type SandboxEgressProfiles ¶ added in v0.6.6
type SandboxEgressProfiles struct {
Refs []models.EgressProfileRef
Inline []string
}
SandboxEgressProfiles is a sandbox's profile references in order, with the generation of each that is live, and its inline allow list. Inline is nil for a sandbox with no profiles: its row's list is the inline one.
type SandboxIdentity ¶ added in v0.6.12
type SandboxIdentity struct {
SandboxID string
OwnerRef string
RoleTag string
Audience string
AWSRoleARN string
AzureClientID string
AzureTenantID string
// TokenExpiresUnix is the exp of the last token pushed; 0 before the
// first push.
TokenExpiresUnix int64
TokenKeyID string
LastError string
}
SandboxIdentity is a sandbox's identity row: what its tokens say and the state of the token now in it.
func (SandboxIdentity) View ¶ added in v0.6.12
func (r SandboxIdentity) View() *models.SandboxIdentity
View is the row as the API shows it.
type SealedColumn ¶ added in v0.6.9
type SealedColumn int
SealedColumn is a column sealed under the server key. A server-key rotation reseals every one of them onto the new key before the old key is retired (plans/customer-key-custody.md §13 step 3).
const ( SealedToolboxToken SealedColumn = iota SealedRegistryAuth SealedMounts SealedEnv )
func (SealedColumn) String ¶ added in v0.6.9
func (c SealedColumn) String() string
type SealedRow ¶ added in v0.6.9
SealedRow is one sealed value: its sandbox, its bytes and the AAD it was sealed with.
type SecretAuditIndexChunk ¶ added in v0.6.1
type SecretAuditIndexChunk struct {
SecretAuditIndexKey
Seq int64
FirstOffset int64
LastOffset int64
MinTime int64
MaxTime int64
LastTime int64
N int
Entries []byte
}
SecretAuditIndexChunk is one bounded slice of a posting list. Entries are encoded relative to FirstOffset, so re-basing a chunk after retention is a column update and never touches the blob.
func NewSecretAuditIndexChunk ¶ added in v0.6.1
func NewSecretAuditIndexChunk(key SecretAuditIndexKey, seq int64, entries []auditlog.IndexEntry) (SecretAuditIndexChunk, error)
NewSecretAuditIndexChunk encodes entries (file order) as chunk seq of key.
func (*SecretAuditIndexChunk) Append ¶ added in v0.6.1
func (c *SecretAuditIndexChunk) Append(entries []auditlog.IndexEntry) error
Append extends the chunk with entries that follow its last one in file order. The row's summary columns supply the delta base, so appending never decodes the existing blob.
func (SecretAuditIndexChunk) Decode ¶ added in v0.6.1
func (c SecretAuditIndexChunk) Decode() ([]auditlog.IndexEntry, error)
Decode returns the chunk's entries with absolute file offsets.
type SecretAuditIndexKey ¶ added in v0.6.1
SecretAuditIndexKey is one posting list: a sandbox lifecycle. Gap markers (which every query must see) live under the empty sandbox id.
type SecretAuditIndexMeta ¶ added in v0.6.1
type SecretAuditIndexMeta struct {
// Generation identifies the file the offsets belong to (hash of its first
// line, as the export cursor uses). Retention rewrites the file and so
// changes it.
Generation string
// IndexedThrough is the byte offset just past the last indexed line. The
// reader scans [IndexedThrough, EOF) itself, so the index may lag the
// file without ever hiding an event.
IndexedThrough int64
// LastLineOffset / LastEventHash pin the last indexed record so boot can
// check, with one read, that the file still holds what the index says.
LastLineOffset int64
LastEventHash string
// AllowBreak carries the chain verifier's checkpoint state across
// batches: true only right after a retention checkpoint.
AllowBreak bool
UpdatedAt time.Time
}
SecretAuditIndexMeta describes how much of the audit file the index covers.
type SecretDeleteOutboxRecord ¶ added in v0.6.1
type SecretDeleteOutboxRecord struct {
SandboxID string
IncarnationID string
Recipients []string
// RecipientCopiedAt is when each recipient's ciphertext copy was
// distributed. Recipients merged into an existing row keep their own
// timestamp, which is the whole point: the row-wide CreatedAt is
// preserved across merges and therefore describes the oldest obligation,
// not this one. Empty for rows written before the column existed;
// callers fall back to CreatedAt there.
RecipientCopiedAt map[string]time.Time
Generation int64
// AwaitingPromotion prevents a staged reseal retirement from deleting the
// only usable old replica before Raft publishes the new generation.
AwaitingPromotion bool
Attempts int
CreatedAt time.Time
UpdatedAt time.Time
}
SecretDeleteOutboxRecord is one durable peer-delete job.
type SecretLifecycleStats ¶ added in v0.6.1
type SecretLifecycleStats struct {
OutboxPending int64
OldestOutbox time.Time
PutOutboxPending int64
OldestPutOutbox time.Time
Tombstones int64
}
SecretLifecycleStats is the bounded-cardinality operator view of durable secret cleanup state. OldestOutbox/OldestPutOutbox are zero when their corresponding queues have no work pending.
type SecretPutOutboxRecord ¶ added in v0.6.1
type SecretPutOutboxRecord struct {
SandboxID string
IncarnationID string
SealGeneration int64
Recipients []string
Attempts int
CreatedAt time.Time
UpdatedAt time.Time
}
SecretPutOutboxRecord is one durable create-path peer fan-out job.
type SnapshotPageQuery ¶ added in v0.6.7
type SnapshotPageQuery struct {
// OwnerRef / Scoped apply owner scoping: Scoped=false returns every
// owner's rows (operator and internal callers).
OwnerRef string
Scoped bool
// SourceSandboxID, when set, keeps only snapshots taken from it.
SourceSandboxID string
// AliasFacade, when set, joins that facade's alias row onto each
// snapshot.
AliasFacade string
// AfterName is the exclusive cursor: rows with a greater name.
AfterName string
// Limit is the number of rows to return; callers ask for one more than
// they show to learn whether another page exists.
Limit int
}
SnapshotPageQuery selects one page of the snapshot catalogue, ordered by name. Name is the primary key, so the cursor is stable across inserts and deletes and each page is an index range scan rather than a sort of the whole catalogue.
type SnapshotPageRow ¶ added in v0.6.7
type SnapshotPageRow struct {
Snapshot *models.SandboxSnapshot
// Alias is nil when the snapshot has no alias for AliasFacade.
Alias *models.SnapshotAlias
}
SnapshotPageRow is one snapshot with its alias for the queried facade.
type SnapshotPushCursor ¶ added in v0.6.12
SnapshotPushCursor is a keyset position in the snapshot push queue. Rows sort by (created_at, owner_ref, name) — oldest first, the primary key breaking ties — so the cursor taken from a page's last row stays valid while rows ahead of it change state or disappear. The zero value starts at the beginning.
func SnapshotPushCursorAfter ¶ added in v0.6.12
func SnapshotPushCursorAfter(snapshot *models.SandboxSnapshot) SnapshotPushCursor
SnapshotPushCursorAfter is the cursor that continues after snapshot.
type SnapshotRegistryRetirement ¶ added in v0.6.12
type SnapshotRegistryRetirement struct {
RegistryRef string
Digest string
OwnerRef string
Name string
ScheduledAt time.Time
Attempts int
LastError string
}
SnapshotRegistryRetirement is the obligation to remove one registry copy of a snapshot that no longer exists on this node: the manifest at RegistryRef@Digest. OwnerRef and Name are the snapshot it was pushed for, so the worker can tell when a re-created snapshot of the same name still has a push to land.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func OpenWithSecretCipher ¶ added in v0.6.1
OpenWithSecretCipher opens the store with the cipher needed to migrate plaintext secret columns created by releases before secrets hardening. New databases can still use Open and configure the cipher later with SetSecretCipher, but production startup must use this entry point so warm upgrades can seal legacy values before the plaintext columns are removed.
func (*Store) AddCustomDomain ¶ added in v0.3.1
func (s *Store) AddCustomDomain(ctx context.Context, sandboxID, hostname string, targetPort int) error
AddCustomDomain inserts a hostname → sandbox mapping. Returns ErrCustomDomainConflict when the hostname is already owned by a different sandbox; returns ErrCustomDomainPortMismatch when the row exists for the same sandbox but with a different targetPort; returns nil when the same (hostname, sandbox, targetPort) tuple already exists (idempotent — the caller may retry safely). targetPort=0 is the toolbox-default sentinel. New rows start in CustomDomainPendingDNS.
func (*Store) AddPendingEgressRuleClear ¶ added in v0.6.6
func (s *Store) AddPendingEgressRuleClear(ctx context.Context, p PendingEgressRuleClear, clearInstalledFor string, now time.Time) (PendingEgressRuleClear, error)
AddPendingEgressRuleClear records that p's rules may be left at its IP, merged into whatever is already pending there, and returns the merged entry. With clearInstalledFor set it also drops that sandbox's installed record in the same transaction: the record's rules now belong to the IP, and a crash between the two writes can't leave them in neither place.
func (*Store) AdoptContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) AdoptContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
AdoptContainerNetnsSlot transitions a realized slot to adopted after the container task is running. Idempotent when already adopted.
func (*Store) AllocateFirecrackerTapSlot ¶ added in v0.4.1
func (s *Store) AllocateFirecrackerTapSlot(ctx context.Context, sandboxID string, now time.Time) (*FirecrackerTapSlot, error)
AllocateFirecrackerTapSlot claims a free slot for sandboxID and returns it. Idempotent: if sandboxID already owns a slot, that slot is returned without changes (the partial unique index guarantees at most one). If no slot is free, returns ErrNoFreeFirecrackerTapSlot.
The claim is one UPDATE that picks its own target and refuses when the sandbox already owns a slot, so concurrent creates never collide and a duplicate call gets the same slot. It used to SELECT a candidate and then UPDATE it if still free, retrying up to 8 times; with more than 8 concurrent callers some ran out of tries while slots were free (see claimContainerNetnsSlot).
func (*Store) AllocateFirecrackerVMMSlot ¶ added in v0.4.1
func (s *Store) AllocateFirecrackerVMMSlot(ctx context.Context, templateID, sandboxID string, now time.Time) (*FirecrackerVMMSlot, error)
AllocateFirecrackerVMMSlot claims one 'loaded' slot for templateID + sandboxID. Idempotent: if sandboxID already owns a slot, that slot is returned without re-allocation. If no 'loaded' slot for templateID exists, returns ErrNoFreeFirecrackerVMMSlot — PR 4-B's caller falls back to cold spawn rather than failing the create.
Same shape as AllocateFirecrackerTapSlot: one UPDATE picks the oldest loaded slot and refuses when the sandbox already owns one, so concurrent creates cannot collide on a slot.
func (*Store) ApplyNetCounterDeltas ¶ added in v0.6.12
func (s *Store) ApplyNetCounterDeltas(ctx context.Context, deltas []NetCounterDelta) ([]NetCounterTotals, error)
ApplyNetCounterDeltas adds each delta to its sandbox's cumulative counters and returns the totals right after, for every sandbox that still exists. A sandbox deleted since the poll, or a zero delta, is skipped without an error. Any negative delta rejects the whole call before anything is written.
Deltas are applied netCounterBatchRows at a time, one transaction each. The netstats poller used to pay one commit plus a four-query re-read per sandbox per poll, all on the single writer (BenchmarkStoreNetstatsTick); the totals now come back from the UPDATE itself. Each UPDATE is atomic, so a sample is applied whole or not at all. On an error the returned totals cover exactly the batches that committed before it.
func (*Store) ApplyPeerSecretDelete ¶ added in v0.6.1
func (s *Store) ApplyPeerSecretDelete(ctx context.Context, sandboxID, incarnationID string, generation int64) error
ApplyPeerSecretDelete tombs + deletes local sealed rows for a peer DELETE. generation gates stale deletes after reseal: if any local row has seal_generation > generation, ACK without deleting (resealed newer data).
func (*Store) BeginPrewarmContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) BeginPrewarmContainerNetnsSlot(ctx context.Context, now time.Time) (*ContainerNetnsSlot, error)
BeginPrewarmContainerNetnsSlot reserves a free slot under its own slot_id so the refill ticker can CNI-realize it without a sandbox owner yet.
func (*Store) BumpSecretDeleteOutboxAttempt ¶ added in v0.6.1
func (s *Store) BumpSecretDeleteOutboxAttempt(ctx context.Context, sandboxID, incarnationID string, generation int64) error
BumpSecretDeleteOutboxAttempt records a delivery attempt (or a local failure worth backing off): attempts grows and the row moves to the back of the fair queue, due again after SecretOutboxRetryDelay.
func (*Store) BumpSecretPutOutboxAttempt ¶ added in v0.6.1
func (s *Store) BumpSecretPutOutboxAttempt(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
BumpSecretPutOutboxAttempt records a delivery attempt (or a local failure worth backing off); see BumpSecretDeleteOutboxAttempt.
func (*Store) CancelRestart ¶ added in v0.6.12
CancelRestart drops a pending restart (a stop, a start, or a timer that wins over it). The failure count stays, so a sandbox that crashes again soon keeps backing off. A non-empty reason replaces the crash's reason on a row that was stopped waiting for the restart: a stop of a sandbox that is already down changes no status, so Upsert would keep "crashed".
func (*Store) ClaimIdempotentRequest ¶ added in v0.1.7
func (s *Store) ClaimIdempotentRequest(ctx context.Context, scope, fingerprint string, now time.Time, pendingTTL time.Duration) (*models.IdempotentRequestRecord, bool, error)
ClaimIdempotentRequest is the generic claim/replay primitive for caller-retry dedupe. scope is a facade-defined namespace string ("e2b.create" today; "daytona.create" or "v1.create" later) so the same fingerprint can be reused across facades without colliding.
Three outcomes per call:
- INSERTed a fresh pending row → acquired=true, caller owns the work.
- Found a Ready row whose ReplayUntil has not expired → acquired=false, caller replays the TargetID instead of running the work again.
- Found a Pending row whose LockedUntil has not expired → acquired=false, caller waits.
Stale Pending or Ready rows past their TTLs are reclaimed as a fresh Pending row (acquired=true), so a crashed claimer cannot block future retries indefinitely.
func (*Store) ClaimPooledContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) ClaimPooledContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
ClaimPooledContainerNetnsSlot hands a prewarmed slot to sandboxID. Idempotent when sandboxID already owns a slot. Returns ErrNoPooledContainerNetnsSlot on miss.
func (*Store) ClaimSnapshotPush ¶ added in v0.6.12
func (s *Store) ClaimSnapshotPush(ctx context.Context, ownerRef, name string) (*models.SandboxSnapshot, time.Time, bool, error)
ClaimSnapshotPush moves one queued snapshot to 'pushing' for this caller, atomically: it matches only while the row is still queued (pending, error, or pushing under an expired claim), so of two workers holding the same listed row exactly one gets it. On success it returns the row as claimed — the image to push is read in the same statement, never from a listing that may predate a delete and re-create — and the claim stamp the completion must present. ok is false, with no error, when another claim owns the row or it is no longer queued (or gone).
func (*Store) ClaimTemplatePush ¶ added in v0.6.12
func (s *Store) ClaimTemplatePush(ctx context.Context, id string) (*models.Template, time.Time, bool, error)
ClaimTemplatePush is ClaimSnapshotPush for the template artifact queue, whose rows are keyed by id.
func (*Store) ClearClusterSecretTombForIncarnation ¶ added in v0.6.1
func (s *Store) ClearClusterSecretTombForIncarnation(ctx context.Context, sandboxID, incarnationID string) error
ClearClusterSecretTombForIncarnation removes one lifecycle's delete fence.
func (*Store) ClearEgressHold ¶ added in v0.6.6
ClearEgressHold lifts the hold whatever its reason.
func (*Store) ClearEgressHoldIf ¶ added in v0.6.6
func (s *Store) ClearEgressHoldIf(ctx context.Context, sandboxID, reason string, now time.Time) (bool, error)
ClearEgressHoldIf lifts a hold only if its reason is still reason, the one the caller resolved, and reports whether it did: a different hold written since is left in place.
func (*Store) ClearInstalledEgress ¶ added in v0.6.6
ClearInstalledEgress drops a sandbox's installed record: its transition applied, and what is installed is what its stored policy installs.
func (*Store) ClearNetworkQuotaExceeded ¶ added in v0.1.7
ClearNetworkQuotaExceeded resets the flag and the detection timestamp. Used when an operator raises the limit (or sets it to unlimited) and the counter is no longer over the new ceiling.
func (*Store) Close ¶
Close closes both pools and then waits, up to storeCloseDrain, for every connection to be closed. database/sql's own Close does not wait for a connection that is checked out: it closes it whenever that query ends. Background work (the secret-delete fanout, the netstats poller) can be mid-read at shutdown, and its late close checkpoints and removes the WAL files after Close has returned, under whoever owns the directory next.
func (*Store) ClusterSecretSealGeneration ¶ added in v0.6.1
func (s *Store) ClusterSecretSealGeneration(ctx context.Context, sandboxID, incarnationID string) (int64, bool, error)
ClusterSecretSealGeneration returns the highest locally stored generation for the exact sandbox lifecycle without loading the encrypted payload.
func (*Store) ClusterSecretSealSummaries ¶ added in v0.6.1
func (s *Store) ClusterSecretSealSummaries(ctx context.Context, refs []string) (map[string]ClusterSecretSealSummary, error)
ClusterSecretSealSummaries reads the summaries for many sealed refs in a handful of round trips instead of one per row. A ref this node does not hold is simply absent from the result. This is the List page's only store work for failover_ready: one query per 500 rows on the single SQLite connection rather than one per row competing with creates.
func (*Store) ClusterSecretTombGenerationForIncarnation ¶ added in v0.6.1
func (s *Store) ClusterSecretTombGenerationForIncarnation(ctx context.Context, sandboxID, incarnationID string) (int64, error)
ClusterSecretTombGenerationForIncarnation returns the deletion fence for an exact lifecycle. A tomb from an older use of the same sandbox ID is not a fence for the replacement incarnation.
func (*Store) CompareCloneGeneration ¶ added in v0.5.3
CompareCloneGeneration rejects stale snapshot writes when wantGen is older than the row's current clone_generation (§4.8 fencing).
func (*Store) CompleteIdempotentRequest ¶ added in v0.1.7
func (s *Store) CompleteIdempotentRequest(ctx context.Context, scope, fingerprint, targetID string, now time.Time, replayTTL time.Duration) error
CompleteIdempotentRequest moves a Pending row to Ready, recording the target ID the work produced and extending the lock-and-replay window out to replayTTL from now. Returns ErrNotFound if no row matched — indicating either a programming error or a too-aggressive cleanup that removed the row mid-flight.
func (*Store) CompleteSnapshotPush ¶ added in v0.6.12
func (s *Store) CompleteSnapshotPush(ctx context.Context, ownerRef, name string, claimedAt time.Time, mode, registryRef, digest string) (bool, error)
CompleteSnapshotPush records a finished push: the registry copy's mode, ref and digest and the 'active' state, in ONE statement, so no reader ever sees a row whose distribution and push state disagree. Fenced by the claim: it applies only while the row is still 'pushing' under claimedAt. applied is false when a newer claim took the row over or the row is gone; the caller then owns nothing and must not write again.
func (*Store) CompleteTemplatePush ¶ added in v0.6.12
func (s *Store) CompleteTemplatePush(ctx context.Context, id string, claimedAt time.Time, registryRef, digest string) (bool, error)
CompleteTemplatePush is CompleteSnapshotPush for templates: registry ref, digest and 'active' land in one fenced statement.
func (*Store) CountDistinctSandboxOwners ¶ added in v0.6.8
CountDistinctSandboxOwners counts the distinct owner_ref values among this node's sandboxes ("" — operator-owned — counts as one), stopping at max: the api-record flood control only needs to know whether a node is shared (plans/identity-and-access.md §5.9, D14), so it asks for 2 and the query never reads past the second owner.
func (*Store) CountSnapshots ¶ added in v0.6.7
func (s *Store) CountSnapshots(ctx context.Context, ownerRef string, scoped bool, sourceSandboxID string) (int, error)
CountSnapshots counts the snapshots a ListSnapshotPage walk with the same owner and source filters would visit. Like the page, it counts through the owner or source index rather than across the catalogue.
func (*Store) CountVolumeAttachments ¶ added in v0.5.4
CountVolumeAttachments returns how many sandbox references currently point at volumeID for tenant. It is backed by idx_volume_attachments_volume and is used on Daytona delete instead of scanning every sandbox's encrypted mounts.
func (*Store) CountVolumes ¶ added in v0.5.4
CountVolumes returns how many volumes tenant owns. Used for per-tenant quota enforcement at create time.
func (*Store) CreateSnapshot ¶ added in v0.1.7
func (*Store) CreateTemplate ¶ added in v0.4.1
CreateTemplate inserts a freshly-allocated template row. Callers set status=pending and an empty rootfs_path; the build goroutine flips both via UpdateTemplateStatus once mkfs returns. A PK collision becomes ErrTemplateIDConflict so an operator pipeline that retries POST with an explicit ID gets a 409 instead of a 500.
func (*Store) CreateVolume ¶ added in v0.5.4
CreateVolume inserts a new volume row. The (tenant, name) unique index makes this the idempotency boundary: a duplicate returns ErrVolumeExists rather than a second row. CreatedAt is stamped here when the caller leaves it zero.
func (*Store) CreateWithSealedEnv ¶ added in v0.6.1
func (s *Store) CreateWithSealedEnv(ctx context.Context, sandbox *models.Sandbox, sealedEnv []byte) error
CreateWithSealedEnv inserts the sandbox row and optional sealed env blob in one transaction so a crash cannot leave a healthy sandbox with empty env (plans/secrets-hardening outside-voice #3). Empty sealedEnv skips the env write (same as Create).
Environment plaintext is never written to the sandbox row; sandbox_env is the only at-rest representation.
func (*Store) CurrentSandboxAuditIdentity ¶ added in v0.6.1
func (s *Store) CurrentSandboxAuditIdentity(ctx context.Context, sandboxID string) (incarnationID, ownerRef string, err error)
CurrentSandboxAuditIdentity returns the live lifecycle id and tenant owner in one read. The audit emit path resolves both on every sandbox start, so they must not cost two round-trips on the single-writer connection.
func (*Store) CurrentSandboxAuditIncarnation ¶ added in v0.6.1
func (s *Store) CurrentSandboxAuditIncarnation(ctx context.Context, sandboxID string) (string, error)
CurrentSandboxAuditIncarnation returns the exact lifecycle linked by the live sandbox row. Retained ACLs are historical authorization records, not a clock-ordered source of truth for the current lifecycle.
func (*Store) DeferSnapshotRegistryRetirement ¶ added in v0.6.12
func (s *Store) DeferSnapshotRegistryRetirement(ctx context.Context, registryRef, digest, failure string) error
DeferSnapshotRegistryRetirement moves an obligation to the back of the queue. A non-empty failure also counts an attempt and keeps the reason, for an operator wondering why a copy is still there.
func (*Store) Delete ¶
Delete removes a sandbox row. The FK cascade takes its volume attachments with it, which can be the last link from any sandbox to a delete_with_sandbox volume; so the same transaction writes the reclaim ledger row (pending_volume_deletions) of every such volume this sandbox was the only holder of. Whatever the caller did or failed to do before, the volume can no longer lose its cleanup record: the reclaim sweep deletes its row and then its bytes. A volume another sandbox still holds is left to that sandbox's delete.
func (*Store) DeleteAPIToken ¶ added in v0.6.8
DeleteAPIToken removes a token. A missing id is not an error (revoke is idempotent); removed reports whether a row went.
func (*Store) DeleteAPITokensExpiredBefore ¶ added in v0.6.8
func (s *Store) DeleteAPITokensExpiredBefore(ctx context.Context, cutoff time.Time) ([]string, error)
DeleteAPITokensExpiredBefore removes every token that expired before cutoff and returns their ids, for the expiry sweep.
func (*Store) DeleteAllWasmCheckpointPushes ¶ added in v0.5.3
DeleteAllWasmCheckpointPushes removes all retained AOCR push-history rows for sandboxID.
func (*Store) DeleteAllWasmStateKV ¶ added in v0.5.3
DeleteAllWasmStateKV removes every durable host-KV row for sandboxID.
func (*Store) DeleteClusterSecretRowsForIncarnation ¶ added in v0.6.1
func (s *Store) DeleteClusterSecretRowsForIncarnation(ctx context.Context, sandboxID, incarnationID string) error
DeleteClusterSecretRowsForIncarnation removes only one sandbox lifecycle. This prevents a delayed teardown from erasing a replacement that reused the same sandbox ID.
func (*Store) DeleteClusterSecretsOriginatorWithOutbox ¶ added in v0.6.1
func (s *Store) DeleteClusterSecretsOriginatorWithOutbox(ctx context.Context, sandboxID, incarnationID string, recipients []string) (generation int64, err error)
DeleteClusterSecretsOriginatorWithOutbox tombs, deletes local rows, and enqueues the peer-delete outbox in one transaction so a crash cannot leave peer credentials without a cleanup job.
func (*Store) DeleteEgressProfile ¶ added in v0.6.6
DeleteEgressProfile removes an owner's profile unless a live sandbox still references it. Deleting a profile that is already gone succeeds, so a retried DELETE converges.
func (*Store) DeleteEnv ¶ added in v0.6.1
DeleteEnv removes sealed env for a sandbox. Cascade on sandboxes covers destroy; explicit deletes are for replace paths.
func (*Store) DeleteExpiredDeletedSandboxViews ¶ added in v0.6.7
func (s *Store) DeleteExpiredDeletedSandboxViews(ctx context.Context, cutoff time.Time, limit int) (int64, error)
DeleteExpiredDeletedSandboxViews removes up to limit tombstones older than cutoff. Batched so one sweep never holds the single writer for long; the created_at index makes the selection a range scan.
func (*Store) DeleteExpiredIdempotentRequests ¶ added in v0.6.7
func (s *Store) DeleteExpiredIdempotentRequests(ctx context.Context, now time.Time, limit int) (int64, error)
DeleteExpiredIdempotentRequests removes up to limit rows that ClaimIdempotentRequest would already treat as free: ready rows past replay_until and pending rows past locked_until. Deleting them changes no claim outcome — a later claim of the same key acquires either way — it only stops the table from growing with every request ever deduped. Batched so one sweep never holds the single writer for long.
func (*Store) DeleteFirecrackerVMMSlot ¶ added in v0.4.1
DeleteFirecrackerVMMSlot drops the row. PR 4-B's GC sweep calls this after the VMM process for the slot is confirmed gone, so there is no on-disk runDir or live socket the row was the last reference to. Returns ErrNotFound when the row was already deleted — idempotent on double-call.
func (*Store) DeleteIdempotentRequest ¶ added in v0.1.7
DeleteIdempotentRequest drops the row outright. Used by failure paths where the in-flight write rolled back and the next retry should run the work again from scratch instead of waiting for LockedUntil.
func (*Store) DeleteIdentityRole ¶ added in v0.6.12
DeleteIdentityRole takes a tag off an owner's allow list. A tag already gone succeeds, so a retried DELETE converges. Sandboxes created with it keep running but get no new token (the refresher checks the list).
func (*Store) DeleteMounts ¶
DeleteMounts removes mount config for a sandbox. The cascade on the sandboxes table handles this when a sandbox is destroyed; explicit deletes are useful for replacing mounts.
func (*Store) DeleteNodeStorageRetirement ¶ added in v0.6.1
DeleteNodeStorageRetirement revokes an attestation. Called by an operator who attested in error, and automatically when a node with that id is alive again — a live node can ACK, so its obligations are real.
func (*Store) DeleteOrphanedWasmStateKV ¶ added in v0.6.1
DeleteOrphanedWasmStateKV removes host-KV rows whose sandbox no longer exists. There is no FK from wasm_state_kv to sandboxes, so destroy must delete children first; this sweep closes any crash or historical vacuum.
func (*Store) DeletePendingImageGC ¶ added in v0.3.1
DeletePendingImageGC removes the ledger row for an image unconditionally. Used when the janitor decides the image is back in use (HasActiveImageRef = true) and the row should be dropped regardless of timestamp — the destroy path will re-schedule with a fresh timestamp if the image goes idle again. Missing rows are not an error.
func (*Store) DeletePendingImageGCIfScheduledAt ¶ added in v0.3.1
func (s *Store) DeletePendingImageGCIfScheduledAt(ctx context.Context, engine, image string, at time.Time) (bool, error)
DeletePendingImageGCIfScheduledAt removes the row only if its scheduled_at still matches `at` — i.e. nobody has refreshed the row since the janitor observed it. Returns whether the delete actually happened so the caller can detect the refresh race.
Why this exists: the sweep does (list, [check active, remove image, delete row]). If a destroy of another sandbox sharing the image upserts the row with a fresh timestamp between the list and the delete, an unconditional delete would silently throw away the extended TTL that destroy was supposed to buy. The janitor uses this to keep the "TTL clock restarts from the most recent destroy" contract under churn.
func (*Store) DeletePendingVolumeDeletion ¶ added in v0.5.4
DeletePendingVolumeDeletion removes a reclaim-ledger row once its backend bytes have been deleted (or skipped because a live volume reclaimed the source). Idempotent: a missing row is success, so the reclaim loop can run at-least-once without tracking which rows it already cleared.
func (*Store) DeletePort ¶
func (*Store) DeleteSecretDeleteOutbox ¶ added in v0.6.1
func (s *Store) DeleteSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, generation int64) error
DeleteSecretDeleteOutbox drops a completed delete fan-out job.
func (*Store) DeleteSecretPutOutbox ¶ added in v0.6.1
func (s *Store) DeleteSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
DeleteSecretPutOutbox drops a completed put fan-out job only when the (sandbox_id, incarnation_id, seal_generation) identity still matches — so a late ACK of an older fan-out cannot clear a newer reseal's outbox.
func (*Store) DeleteSnapshot ¶ added in v0.1.7
DeleteSnapshot removes a snapshot row and records no registry retirement; see DeleteSnapshotRetiringRegistryCopy.
func (*Store) DeleteSnapshotAlias ¶ added in v0.1.7
DeleteSnapshotAlias removes the alias row. FK cascade also drops the row when its underlying sandbox_snapshots row is deleted, so explicit deletes are only needed when the facade wants to forget an alias without removing the native snapshot.
func (*Store) DeleteSnapshotRegistryRetirement ¶ added in v0.6.12
func (s *Store) DeleteSnapshotRegistryRetirement(ctx context.Context, registryRef, digest string) error
DeleteSnapshotRegistryRetirement drops a fulfilled (or void) obligation.
func (*Store) DeleteSnapshotRetiringRegistryCopy ¶ added in v0.6.12
func (s *Store) DeleteSnapshotRetiringRegistryCopy(ctx context.Context, ownerRef, name, pushedRef string) (retErr error)
DeleteSnapshotRetiringRegistryCopy deletes a snapshot row and, in the same transaction, records the obligation to retire its registry copy — but only a copy this node's push reconciler made. pushedRef is the ref the reconciler pushes this snapshot to ("" when no registry is configured: no obligation then). The obligation is written only when the row, as it is at the moment of the delete, carries exactly that ref with a digest, and its image is not that ref itself (a snapshot registered with a registry image names a copy someone else owns).
Reading the row inside the transaction is what makes this race-free with the push worker: a push that completes just before the delete is seen here, and one that completes just after finds the row gone and records its own obligation (ScheduleSnapshotRegistryRetirement).
func (*Store) DeleteTeamQuota ¶ added in v0.6.12
DeleteTeamQuota removes a team's quota. Deleting one that is already gone succeeds, so a retried DELETE converges.
func (*Store) DeleteTemplate ¶ added in v0.4.1
func (*Store) DeleteVolume ¶ added in v0.5.4
DeleteVolume removes the volume id owned by tenant. Returns ErrNotFound when no such row exists so the facade can answer 404 rather than a silent 200. Callers MUST enforce the no-live-attacher rule before calling this; the store only owns the row.
func (*Store) DeleteVolumeAttachmentsForSandbox ¶ added in v0.5.4
func (s *Store) DeleteVolumeAttachmentsForSandbox(ctx context.Context, sandboxID, incarnationID string) error
DeleteVolumeAttachmentsForSandbox removes the indexed platform-volume references for sandboxID. SQLite normally reaches this through the sandbox FK cascade, but the explicit method lets service code share the cluster-mode cleanup path and is idempotent for rollback.
func (*Store) DeleteVolumeIfNoAttachments ¶ added in v0.6.12
DeleteVolumeIfNoAttachments removes the volume row only while no attachment references it, in one statement, so an attach racing the delete either lands first (ErrVolumeInUse, the row stays) or finds the row gone (its FK fails and that create rolls back). A count read before a plain DeleteVolume cannot promise that: the FK cascade would silently remove the racing sandbox's attachment along with the row. This is the rule the cluster FSM's opDeleteVolume already applies. ErrNotFound when no such row.
func (*Store) DeleteVolumeIfUnattached ¶ added in v0.5.4
func (s *Store) DeleteVolumeIfUnattached(ctx context.Context, tenant, id, fallbackSource string) error
DeleteVolumeIfUnattached schedules backend cleanup and removes the volume row only when no indexed attachments remain. The pending cleanup row is inserted in the same transaction before the metadata row is removed, so remote data never loses its reconciliation coordinates.
fallbackSource is used only for rows created before the source column existed (vol.Source == ""); the frozen vol.Source is authoritative when present, so reclaim always targets exactly what was created even if config later changed.
func (*Store) DeleteWarmPool ¶ added in v0.6.12
DeleteWarmPool removes the entry for an image. Deleting one that is already gone succeeds, so a retried DELETE converges.
func (*Store) DeleteWasmCheckpointPush ¶ added in v0.5.3
DeleteWasmCheckpointPush removes one push history row by id.
func (*Store) DeleteWasmModule ¶ added in v0.5.3
DeleteWasmModule removes the catalogue row id in ownerRef's namespace only; another owner's row with the same id is never touched.
func (*Store) DeleteWasmStateKV ¶ added in v0.5.3
DeleteWasmStateKV removes one durable host-KV row.
func (*Store) EnsureWasmCheckpointCleanupRef ¶ added in v0.6.1
func (s *Store) EnsureWasmCheckpointCleanupRef(ctx context.Context, sandboxID, registryRef string) (int64, error)
EnsureWasmCheckpointCleanupRef durably records an external ref before a destroy path attempts to delete it. It is idempotent for a sandbox/ref pair, allowing the orphan sweep to finish cleanup after the sandbox row is gone.
func (*Store) FinishPrewarmContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) FinishPrewarmContainerNetnsSlot(ctx context.Context, slotID, netnsPath, containerIP string, now time.Time) error
FinishPrewarmContainerNetnsSlot moves a refill-reserved slot into the pooled warm queue (network prepaid, no sandbox owner).
func (*Store) FreeReleasingContainerNetnsSlot ¶ added in v0.6.9
func (s *Store) FreeReleasingContainerNetnsSlot(ctx context.Context, slotID string, now time.Time) error
FreeReleasingContainerNetnsSlot returns a releasing slot to the free pool once its host teardown has finally succeeded. A no-op for any other state.
func (*Store) GetClusterSecret ¶ added in v0.2.1
func (*Store) GetClusterSecretForSandboxIncarnation ¶ added in v0.6.1
func (s *Store) GetClusterSecretForSandboxIncarnation(ctx context.Context, sandboxID, incarnationID string) (*ClusterSecretRecord, error)
GetClusterSecretForSandboxIncarnation returns only the current-format row for an exact sandbox lifecycle. Sandbox IDs can be reused, so reconciliation and readiness code must not select a higher-generation row from an older incarnation.
func (*Store) GetCompatState ¶ added in v0.1.7
func (s *Store) GetCompatState(ctx context.Context, sandboxID, facade string) (*models.SandboxCompatState, error)
GetCompatState returns the state blob for (sandboxID, facade), or ErrNotFound when no row exists. Callers unmarshal state_json themselves.
func (*Store) GetContainerNetnsPoolStats ¶ added in v0.5.6
func (s *Store) GetContainerNetnsPoolStats(ctx context.Context) (ContainerNetnsPoolStats, error)
func (*Store) GetContainerNetnsSlotBySandbox ¶ added in v0.5.6
func (s *Store) GetContainerNetnsSlotBySandbox(ctx context.Context, sandboxID string) (*ContainerNetnsSlot, error)
GetContainerNetnsSlotBySandbox returns the slot owned by sandboxID, or nil.
func (*Store) GetCreateRequestDigest ¶ added in v0.6.9
GetCreateRequestDigest returns the request digest a sandbox's keyed create stored, or "" when it has none (a create without a key, a server without a key, or a row made before digests were kept).
func (*Store) GetDeletedSandboxView ¶ added in v0.6.7
func (s *Store) GetDeletedSandboxView(ctx context.Context, sandboxID, facade string) (*DeletedSandboxView, error)
GetDeletedSandboxView returns the tombstone for (sandboxID, facade), or ErrNotFound. Owner scoping and the replay-window check are the service's job — the store returns the row as stored.
func (*Store) GetEgressProfile ¶ added in v0.6.6
func (s *Store) GetEgressProfile(ctx context.Context, owner, name string) (models.EgressProfile, error)
GetEgressProfile returns an owner's profile.
func (*Store) GetEgressState ¶ added in v0.6.6
GetEgressState returns a sandbox's egress state; a sandbox with no row has the zero state (no hold).
func (*Store) GetEnv ¶ added in v0.6.1
GetEnv returns the encrypted env blob, or ErrNotFound if no row exists.
func (*Store) GetEnvWithIdentity ¶ added in v0.6.1
func (s *Store) GetEnvWithIdentity(ctx context.Context, sandboxID string) (blob []byte, present bool, incarnationID, ownerRef string, err error)
GetEnvWithIdentity reads ciphertext and its local lifecycle in one snapshot. A cached Raft incarnation or two separate queries could bind an env read to a replacement sandbox while the local row is being destroyed/recreated.
present distinguishes an env row holding an empty seal (the sandbox has no environment — the normal case, written at create) from no env row at all (the row was lost). Both scan to a zero-length blob, so callers that must fail loud on loss cannot use the blob length alone. ErrNotFound still means the SANDBOX row is missing, not the env row.
func (*Store) GetFirecrackerTapPoolStats ¶ added in v0.4.1
func (s *Store) GetFirecrackerTapPoolStats(ctx context.Context) (FirecrackerTapPoolStats, error)
func (*Store) GetFirecrackerTapSlotBySandbox ¶ added in v0.4.1
func (s *Store) GetFirecrackerTapSlotBySandbox(ctx context.Context, sandboxID string) (*FirecrackerTapSlot, error)
GetFirecrackerTapSlotBySandbox returns the slot currently owned by sandboxID, or nil if it owns none. Used by both the idempotent allocate path and the runtime driver's Inspect/Destroy paths.
func (*Store) GetFirecrackerVMMPoolStats ¶ added in v0.4.1
func (s *Store) GetFirecrackerVMMPoolStats(ctx context.Context, templateID string) (FirecrackerVMMPoolStats, error)
GetFirecrackerVMMPoolStats returns per-template occupancy by status. Single GROUP BY scan covered by idx_firecracker_vmm_pool_template_status. /healthz and PR 4-C's metrics exporter both call this; PR 4-B's refill goroutine prefers ListFirecrackerVMMSlotsForRefill which gives it the row ids it may want to act on.
func (*Store) GetFirecrackerVMMSlotByID ¶ added in v0.4.1
func (s *Store) GetFirecrackerVMMSlotByID(ctx context.Context, slotID string) (*FirecrackerVMMSlot, error)
GetFirecrackerVMMSlotByID returns the slot row whose id matches, or nil if not found. Lets PR 4-B's refill goroutine re-read its own freshly-inserted row to inspect the row's authoritative status (the daemon may have raced a GC between InsertFirecrackerVMMSlot and the spawner attempt). Unlike GetFirecrackerVMMSlotBySandbox, the row's sandbox_id is unknown to the caller — we project the column explicitly so an 'allocated' slot reads back with its claimant.
func (*Store) GetFirecrackerVMMSlotBySandbox ¶ added in v0.4.1
func (s *Store) GetFirecrackerVMMSlotBySandbox(ctx context.Context, sandboxID string) (*FirecrackerVMMSlot, error)
GetFirecrackerVMMSlotBySandbox returns the slot currently claimed by sandboxID, or nil if it owns none. Used by the idempotent Allocate pre-check and by PR 4-B's destroy path to find the slot whose VMM process needs to be torn down.
func (*Store) GetIdempotentRequest ¶ added in v0.1.7
func (s *Store) GetIdempotentRequest(ctx context.Context, scope, fingerprint string) (*models.IdempotentRequestRecord, error)
GetIdempotentRequest returns the row for (scope, fingerprint), or ErrNotFound when no row exists.
func (*Store) GetIdentityRole ¶ added in v0.6.12
func (s *Store) GetIdentityRole(ctx context.Context, owner, tag string) (models.IdentityRole, error)
GetIdentityRole returns one tag of an owner's allow list.
func (*Store) GetMounts ¶
GetMounts returns the encrypted mount blob, or ErrNotFound if no row exists.
func (*Store) GetOrCreateVolume ¶ added in v0.5.4
func (s *Store) GetOrCreateVolume(ctx context.Context, v *models.Volume, maxPerTenant int) (*models.Volume, bool, error)
GetOrCreateVolume returns the existing (tenant,name) volume or inserts v as a new row when absent. The existence check, quota check, and insert run in one transaction so concurrent creates for different names cannot both observe the same pre-insert count and overshoot maxPerTenant. created is true only when a row was inserted by this call.
func (*Store) GetPort ¶ added in v0.6.12
func (s *Store) GetPort(ctx context.Context, sandboxID string, port int) (*models.ExposedPort, error)
GetPort returns the exposure row for (sandboxID, port), or nil if absent. One primary-key lookup: the service's route writers read a port's gate here right before they write its route, rather than trusting the copy in a sandbox row they read earlier.
func (*Store) GetPortByHostPort ¶ added in v0.2.4
GetPortByHostPort returns the raw-TCP exposure bound to hostPort, or nil if no exposure owns it. The L4 wake listener uses this to map Caddy's PROXY protocol destination port back to a sandbox/container port.
func (*Store) GetSandboxAuditACLOwnerRef ¶ added in v0.6.1
func (s *Store) GetSandboxAuditACLOwnerRef(ctx context.Context, sandboxID, incarnationID string) (string, error)
GetSandboxAuditACLOwnerRef returns the retained audit OwnerRef for the exact (sandbox, incarnation) pair. Empty lifecycle identifiers are rejected rather than treated as wildcards or legacy rows.
func (*Store) GetSandboxEgressProfiles ¶ added in v0.6.6
func (s *Store) GetSandboxEgressProfiles(ctx context.Context, sandboxID string) (SandboxEgressProfiles, error)
GetSandboxEgressProfiles returns a sandbox's profile state.
func (*Store) GetSandboxIdentity ¶ added in v0.6.12
GetSandboxIdentity returns a sandbox's identity row.
func (*Store) GetSandboxesEgressProfiles ¶ added in v0.6.6
func (s *Store) GetSandboxesEgressProfiles(ctx context.Context, ids []string) (map[string]SandboxEgressProfiles, error)
GetSandboxesEgressProfiles returns the profile state of several sandboxes in two queries, for list pages. Sandboxes with no profiles are absent.
func (*Store) GetSecretAuditIndexMeta ¶ added in v0.6.1
GetSecretAuditIndexMeta returns the stored coverage, or ok=false when the index has never been built.
func (*Store) GetSecretDeleteOutboxForIncarnation ¶ added in v0.6.1
func (s *Store) GetSecretDeleteOutboxForIncarnation(ctx context.Context, sandboxID, incarnationID string) (*SecretDeleteOutboxRecord, error)
GetSecretDeleteOutbox returns one outbox row when present. GetSecretDeleteOutboxForIncarnation returns the pending cleanup obligation for one exact lifecycle.
func (*Store) GetSecretPutOutboxForIncarnation ¶ added in v0.6.1
func (s *Store) GetSecretPutOutboxForIncarnation(ctx context.Context, sandboxID, incarnationID string) (*SecretPutOutboxRecord, error)
GetSecretPutOutboxForIncarnation returns the active fan-out obligation for one exact lifecycle.
func (*Store) GetSnapshot ¶ added in v0.1.7
func (*Store) GetSnapshotAlias ¶ added in v0.1.7
GetSnapshotAlias returns the alias row, or ErrNotFound if the alias does not exist.
func (*Store) GetSnapshotByNames ¶ added in v0.6.7
func (s *Store) GetSnapshotByNames(ctx context.Context, ownerRef string, names []string) (*models.SandboxSnapshot, error)
GetSnapshotByNames returns the snapshot whose name is the earliest of names that one exists for, in one primary-key lookup per name and one statement. The create path resolves an image through it with every spelling the engine treats as that image, so "snap:latest" cannot reach snapshot "snap" without its owner check.
func (*Store) GetSnapshotsByImage ¶ added in v0.6.7
func (s *Store) GetSnapshotsByImage(ctx context.Context, images []string) ([]*models.SandboxSnapshot, error)
GetSnapshotsByImage returns the snapshots whose image is any of images, ordered by name: the snapshot an image was committed for, and any registered under that image.
func (*Store) GetTeamQuota ¶ added in v0.6.12
GetTeamQuota returns a team's quota, or models.ErrTeamQuotaNotFound.
func (*Store) GetTemplate ¶ added in v0.4.1
func (*Store) GetVolume ¶ added in v0.5.4
GetVolume returns the volume named name owned by tenant, or ErrNotFound.
func (*Store) GetVolumeByID ¶ added in v0.5.4
GetVolumeByID returns the volume with the given id scoped to tenant (so one tenant cannot resolve another's id), or ErrNotFound.
func (*Store) GetWarmPool ¶ added in v0.6.12
GetWarmPool returns the entry for an image.
func (*Store) GetWasmModule ¶ added in v0.5.3
GetWasmModule returns the catalogue row id in exactly ownerRef's namespace ("" is the operator namespace). It never falls back to another namespace: create's id-conflict check and delete must only ever see the caller's rows.
func (*Store) GetWasmStateKV ¶ added in v0.5.3
GetWasmStateKV returns one durable host-KV value.
func (*Store) HasActiveImageRef ¶
HasActiveImageRef reports whether any sandbox row references image with a status other than destroyed, or any snapshot holds it. Used by image GC: when this returns false the caller may safely remove the image from Docker. A snapshot's image has no sandbox using it most of the time — a sandbox started from it and since destroyed is what schedules it for GC — yet removing it would leave the snapshot pointing at nothing. Two indexed lookups — constant cost regardless of how many destroyed rows have accumulated, so 10k destroyed historical rows do not slow the destroy hot path. Returns true on empty image as a conservative default (caller treats it as "still in use, do not delete").
func (*Store) HasSandbox ¶ added in v0.6.9
HasSandbox reports whether a sandbox row exists for id. It reads no sealed column, so it answers on a node whose server key is revoked.
func (*Store) HasSandboxAuditACL ¶ added in v0.6.1
func (s *Store) HasSandboxAuditACL(ctx context.Context, sandboxID, incarnationID string) (bool, error)
HasSandboxAuditACL reports whether the exact retained sandbox incarnation exists, including operator-owned rows whose owner_ref is intentionally empty.
func (*Store) InsertAPIToken ¶ added in v0.6.8
InsertAPIToken stores a new token. It never replaces one: a duplicate id is ErrAPITokenIDTaken and a duplicate (team, name) ErrAPITokenNameTaken.
func (*Store) InsertFirecrackerVMMSlot ¶ added in v0.4.1
func (s *Store) InsertFirecrackerVMMSlot(ctx context.Context, slot FirecrackerVMMSlot, now time.Time) error
InsertFirecrackerVMMSlot reserves a new row in status='spawning'. PR 4-B's refill goroutine calls this BEFORE launching firecracker so a crash mid-spawn leaves a 'spawning' row the GC sweep can clean up rather than a silently-leaked process with no row to find it by.
Validation is strict because a malformed insert is always a bug in the caller — the refill goroutine should hand us a freshly-generated id and an actual template id, not the zero value.
func (*Store) InsertWasmCheckpointPush ¶ added in v0.5.3
func (s *Store) InsertWasmCheckpointPush(ctx context.Context, sandboxID, incarnationID, registryRef, digest string) (int64, error)
InsertWasmCheckpointPush records a successful AOCR push for keep-last-N retention.
func (*Store) IsTemplateReferenced ¶ added in v0.4.1
IsTemplateReferenced reports whether any sandbox row still names this template_id. Used by DeleteTemplate (so an operator gets a 409 instead of yanking the rootfs out from under a live sandbox) and by the GC sweep (so it skips rows that are still in use). Backed by the partial index idx_sandboxes_template_id — constant cost regardless of the destroyed-row history.
func (*Store) IsTemplateReferencedByVMM ¶ added in v0.4.1
IsTemplateReferencedByVMM reports whether any warm-VMM pool row still names this template. This intentionally includes released rows: even a released row is still persistent state that references the template, and template GC should not leave dangling pool rows behind. Once the VMM-pool GC deletes the row, template GC can remove the template on a later pass.
func (*Store) IsWasmDigestCatalogued ¶ added in v0.5.3
IsWasmDigestCatalogued reports whether any wasm_modules row pins this content digest. The cache evictor consults it (alongside IsWasmModuleReferenced) so a digest that backs a catalogue id — resolvable later by a fresh create — is never reclaimed out from under the catalogue, even with no live sandbox.
func (*Store) IsWasmDigestCataloguedElsewhere ¶ added in v0.6.8
func (s *Store) IsWasmDigestCataloguedElsewhere(ctx context.Context, ownerRef, id, digest string) (bool, error)
IsWasmDigestCataloguedElsewhere reports whether any catalogue row other than (ownerRef, id) pins digest. Catalogue ids are per owner but the bytes behind them are content-addressed and shared on the host (one cache file, one warm pool target per digest), so removing one owner's row must leave the bytes and the warm target in place while another row still points at them.
func (*Store) IsWasmModuleReferenced ¶ added in v0.5.3
func (s *Store) IsWasmModuleReferenced(ctx context.Context, moduleID, moduleRef, moduleDigest string) (bool, error)
IsWasmModuleReferenced reports whether any sandbox still names moduleRef or digest id. IsWasmModuleReferenced reports whether any sandbox row still depends on this module. The check spans ref, id, AND the resolved content digest: two aliases/tags can share the same bytes, so deleting/evicting purely by ref would yank a digest still in use by another sandbox (codex C5). A blank moduleDigest simply contributes no extra match.
func (*Store) IsWasmModuleReferencedByOwner ¶ added in v0.6.8
func (s *Store) IsWasmModuleReferencedByOwner(ctx context.Context, ownerRef, moduleID, moduleRef, moduleDigest string) (bool, error)
IsWasmModuleReferencedByOwner is IsWasmModuleReferenced narrowed to the sandboxes ownerRef owns. A tenant's catalogue row can only be resolved by that tenant's own creates, so only its sandboxes can depend on the row; a delete gated on this check never tells the tenant that another owner runs the same bytes.
func (*Store) LatestRetainedSandboxAuditIncarnation ¶ added in v0.6.1
func (s *Store) LatestRetainedSandboxAuditIncarnation(ctx context.Context, sandboxID string) (string, error)
LatestRetainedSandboxAuditIncarnation resolves the most recently refreshed retained ACL when no live sandbox row exists. It exists only for the audit API's implicit-incarnation query; lifecycle mutation code must use CurrentSandboxAuditIncarnation and therefore cannot bind to historical data.
func (*Store) LatestSecretAuditIndexChunks ¶ added in v0.6.1
func (s *Store) LatestSecretAuditIndexChunks(ctx context.Context, keys []SecretAuditIndexKey) (map[SecretAuditIndexKey]SecretAuditIndexChunk, error)
LatestSecretAuditIndexChunks returns the open (highest-seq) chunk of each requested posting list, for appending. Missing keys are absent from the map.
func (*Store) ListAPITokens ¶ added in v0.6.8
ListAPITokens returns every stored token, sorted by team and name.
func (*Store) ListAllCustomDomains ¶ added in v0.3.1
func (s *Store) ListAllCustomDomains(ctx context.Context) ([]CustomDomainRow, error)
ListAllCustomDomains returns every row in the table. Used by the reconcile loop's matcher-GC pass and by the cluster FSM hydration on cold start. Ordered by hostname so reconcile diffs are stable across calls.
func (*Store) ListAllExposedPorts ¶ added in v0.1.4
ListAllExposedPorts returns every row in exposed_ports across every sandbox. Used by reconcile to GC zombie caddy routes / layer4 servers without N+1 per-sandbox lookups.
func (*Store) ListAutoImportPendingIDs ¶ added in v0.2.3
ListAutoImportPendingIDs returns the IDs of sandboxes whose post-pull auto-import has not yet succeeded. Returns IDs only (not full Sandbox rows) so the reconciler can fetch+retry one at a time and skip rows that have meanwhile been deleted without holding a large in-memory snapshot. Hits the partial index on (auto_import_pending = 1).
func (*Store) ListByOwner ¶ added in v0.5.1
ListByOwner returns the sandboxes attributed to ownerRef, newest first. It is the owner-scoped counterpart of List: the API edge uses it to fence a user token to its own sandboxes, and the fleet enforcement loop uses it to fan a standing directive (stop/restore/delete) across one account. An empty ownerRef matches operator/PAT-created rows; callers that want the whole fleet use List instead. Ports and custom domains are intentionally not attached here — the current callers (scoping filter, enforcement) only need identity and lifecycle fields, so we skip the bulk joins.
func (*Store) ListByRuntime ¶ added in v0.5.3
ListByRuntime returns the sandboxes for one runtime ("wasm", "firecracker", "docker"), newest first. It is the runtime-scoped counterpart of List: the per-runtime background sweeps (wasm periodic checkpoint, wasm durable-push retry) use it instead of List so they scan only their own rows rather than the whole fleet on every tick — at a node packing thousands of mixed-runtime sandboxes, List would load every docker/firecracker row just to filter them back out. Like ListByOwner, ports and custom domains are not attached: the sweep callers only need identity + lifecycle fields. Toolbox tokens stay sealed; those sweeps never need the bearer.
func (*Store) ListClusterSecretsBatch ¶ added in v0.6.1
func (s *Store) ListClusterSecretsBatch(ctx context.Context, afterRef string, limit int) ([]ClusterSecretRecord, error)
ListClusterSecretsBatch returns the next ref-ordered page after afterRef. Boot reconciliation must remain memory-bounded at the 100k-sandbox target, so there is deliberately no all-rows convenience API.
func (*Store) ListCompatState ¶ added in v0.1.7
func (s *Store) ListCompatState(ctx context.Context, facade string) (map[string]models.SandboxCompatState, error)
ListCompatState returns every row for the given facade keyed by sandbox_id. Empty result is map of length zero, not nil — callers can always index into it.
func (*Store) ListCompatStateByOwner ¶ added in v0.6.7
func (s *Store) ListCompatStateByOwner(ctx context.Context, facade, ownerRef string) (map[string]models.SandboxCompatState, error)
ListCompatStateByOwner is ListCompatState narrowed to one owner's sandboxes, joining sandbox_compat_state to sandboxes on the id. A scoped caller (a user token) only ever needs its own rows, so the service uses this instead of scanning every tenant's compat rows on each list — the fleet-wide scan is a real cost at 100k sandboxes, and returning only the owner's rows keeps the owner check inside the shared helper rather than relying on the caller.
func (*Store) ListContainerNetnsSlotsByState ¶ added in v0.5.6
func (s *Store) ListContainerNetnsSlotsByState(ctx context.Context, state string) ([]ContainerNetnsSlot, error)
ListContainerNetnsSlotsByState returns all rows in the given state.
func (*Store) ListCustomDomains ¶ added in v0.3.1
func (s *Store) ListCustomDomains(ctx context.Context, sandboxID string) ([]models.CustomDomain, error)
ListCustomDomains returns the canonical-ordered rows for one sandbox. Empty slice (nil) when the sandbox has no custom domains.
func (*Store) ListDueSnapshotRegistryRetirements ¶ added in v0.6.12
func (s *Store) ListDueSnapshotRegistryRetirements(ctx context.Context, now time.Time, limit int) ([]SnapshotRegistryRetirement, error)
ListDueSnapshotRegistryRetirements returns up to limit obligations due by now, the longest-waiting first. A deferred or failed obligation is pushed to the back (DeferSnapshotRegistryRetirement), so a few that cannot finish never starve the rest of a bounded batch.
func (*Store) ListEgressHolds ¶ added in v0.6.6
ListEgressHolds returns every held sandbox and its reason (reconcile retries, the held-sandboxes gauge). The partial index keeps it to held rows.
func (*Store) ListEgressProfiles ¶ added in v0.6.6
func (s *Store) ListEgressProfiles(ctx context.Context, owner, after string, limit int) ([]models.EgressProfile, error)
ListEgressProfiles returns up to limit of an owner's profiles by name, starting after the name in after.
func (*Store) ListFirecrackerVMMSlotsForRefill ¶ added in v0.4.1
func (s *Store) ListFirecrackerVMMSlotsForRefill(ctx context.Context, templateID string) ([]FirecrackerVMMSlot, error)
ListFirecrackerVMMSlotsForRefill returns every non-released slot owned by templateID. PR 4-B's refill goroutine calls this once per tick to compute "desired_depth - len(non_released)" — the spawn budget for the next pass. Released rows are excluded so a slow GC doesn't inflate the count and starve refills.
func (*Store) ListGCEligibleTemplates ¶ added in v0.4.1
func (s *Store) ListGCEligibleTemplates(ctx context.Context, olderThan time.Time) ([]*models.Template, error)
ListGCEligibleTemplates returns ready/failed templates not referenced by any sandbox and last touched before olderThan. Pending rows are skipped — they have an in-flight build goroutine that owns the row's terminal transition. The anti-join against sandboxes uses the idx_sandboxes_template_id partial index so the subquery is cheap.
func (*Store) ListIdempotentRequests ¶ added in v0.6.7
func (s *Store) ListIdempotentRequests(ctx context.Context, scope, state, afterFingerprint string, limit int) ([]*models.IdempotentRequestRecord, error)
ListIdempotentRequests returns up to limit rows of one scope in one state whose fingerprint sorts after afterFingerprint, in fingerprint order. It lets a claimer that keeps work outstanding under its pending rows (the Runloop execution ledger) find all of that work again after a restart: the caller passes the last fingerprint of each page to get the next, so no backlog is too large to walk. idx_request_idempotency_state makes each page a range seek that never touches the scope's rows in other states.
func (*Store) ListIdentityRoles ¶ added in v0.6.12
func (s *Store) ListIdentityRoles(ctx context.Context, owner, after string, limit int) ([]models.IdentityRole, error)
ListIdentityRoles returns up to limit of an owner's tags, by tag, after the tag in after.
func (*Store) ListInstalledEgress ¶ added in v0.6.6
ListInstalledEgress returns the sandboxes with an installed record: those whose last policy transition hasn't finished.
func (*Store) ListNodeStorageRetirements ¶ added in v0.6.1
func (s *Store) ListNodeStorageRetirements(ctx context.Context) ([]NodeStorageRetirement, error)
ListNodeStorageRetirements returns every recorded attestation. The set is bounded by the number of nodes an operator has ever decommissioned, so it is read whole and cached by the caller for a maintenance tick.
func (*Store) ListNonFreeContainerNetnsSlots ¶ added in v0.5.6
func (s *Store) ListNonFreeContainerNetnsSlots(ctx context.Context) ([]ContainerNetnsSlot, error)
ListNonFreeContainerNetnsSlots returns rows not in the free state for reconcile.
func (*Store) ListOrphanedWasmCheckpointPushes ¶ added in v0.5.3
func (s *Store) ListOrphanedWasmCheckpointPushes(ctx context.Context, limit int) ([]WasmCheckpointPushRecord, error)
ListOrphanedWasmCheckpointPushes returns push-history rows whose sandbox no longer exists, capped at limit (<=0 means a default cap). These are the rows a destroy/reconcile retained because its registry DeleteRef had not yet succeeded; the orphan-ref sweep retries each ref and drops the row once the manifest is confirmed gone, so the tracking table can never leak unbounded rows for sandboxes that are already gone.
A row is orphaned when no LIVE sandbox lifetime owns it. For a row that names its incarnation that means no sandbox row carries that id AND that incarnation — the sandbox id alone is not enough, because a destroyed sandbox's id can be re-created, and a push the fenced metadata write rejected as belonging to the dead lifetime was otherwise never reclaimed: the id existed, so the row never looked orphaned. Cleanup-only rows carry no incarnation and fall back to the id rule.
func (*Store) ListPendingEgressRuleClears ¶ added in v0.6.6
func (s *Store) ListPendingEgressRuleClears(ctx context.Context) ([]PendingEgressRuleClear, error)
ListPendingEgressRuleClears returns every pending rule clear.
func (*Store) ListPendingImageGCDue ¶ added in v0.3.1
func (s *Store) ListPendingImageGCDue(ctx context.Context, cutoff time.Time, limit int) ([]PendingImageGCEntry, error)
ListPendingImageGCDue returns rows whose scheduled_at is at or before cutoff (the janitor passes now - ImageBuildGCTTL). Ordered by scheduled_at so the oldest entries get GC'd first within a sweep. `limit` caps the batch so a backlog (janitor disabled for a while then re-enabled, or just thousands of destroyed sandboxes sharing a few images) doesn't fan out into one huge serial Docker spike per tick — pass 0 for unbounded. scheduled_at is returned so the caller can guard the conditional delete in DeletePendingImageGCIfScheduledAt.
func (*Store) ListPendingVolumeDeletions ¶ added in v0.5.4
func (s *Store) ListPendingVolumeDeletions(ctx context.Context) ([]models.PendingVolumeDeletion, error)
ListPendingVolumeDeletions exposes the durable cleanup ledger for tests and future backend-specific reclaim loops.
func (*Store) ListPorts ¶ added in v0.6.12
ListPorts returns every exposure row of one sandbox, ordered by port. The narrow read (no sandbox row, no token decrypt) the toolboxd allowlist push makes under its lock.
func (*Store) ListReadyTemplateIDs ¶ added in v0.4.1
ListReadyTemplateIDs returns the IDs whose artifacts are usable on this host. The administrative catalogue is intentionally discarded here.
func (*Store) ListReadyWasmModuleRefs ¶ added in v0.5.3
ListReadyWasmModuleRefs returns the distinct module_ref values of ready catalogue rows. It is a per-host placement inventory ("which module bytes can this node boot"), so it spans every owner's namespace; DISTINCT keeps two owners' rows for the same ref from doubling the gossiped list.
func (*Store) ListReleasedFirecrackerVMMSlots ¶ added in v0.4.1
func (s *Store) ListReleasedFirecrackerVMMSlots(ctx context.Context, olderThan time.Time) ([]FirecrackerVMMSlot, error)
ListReleasedFirecrackerVMMSlots is the GC sweep selector: every row in status='released' whose released_at is older than olderThan. The partial index on released_at WHERE status='released' covers this query exactly so the sweep is cheap even when the steady-state count is zero.
func (*Store) ListRollbackPendingIDs ¶ added in v0.6.12
ListRollbackPendingIDs returns the ids of rows marked rollback-pending, least recently written first. It hits the partial index on (rollback_pending = 1), so it is an empty probe in the steady state.
func (*Store) ListSealedRows ¶ added in v0.6.9
func (s *Store) ListSealedRows(ctx context.Context, col SealedColumn, afterID string, limit int) ([]SealedRow, error)
ListSealedRows returns the next sandbox-ordered page of a sealed column after afterID. Empty values (no credentials) are skipped.
func (*Store) ListSecretDeleteOutboxBatch ¶ added in v0.6.1
func (s *Store) ListSecretDeleteOutboxBatch(ctx context.Context, limit int) ([]SecretDeleteOutboxRecord, error)
ListSecretDeleteOutboxBatch returns at most limit pending jobs in fair retry order. Requiring an explicit positive bound prevents diagnostics or future callers from accidentally loading a 100k-sandbox backlog into memory.
func (*Store) ListSecretDeleteOutboxDue ¶ added in v0.6.1
func (s *Store) ListSecretDeleteOutboxDue(ctx context.Context, now time.Time, limit int) ([]SecretDeleteOutboxRecord, error)
ListSecretDeleteOutboxDue is ListSecretDeleteOutboxBatch restricted to rows whose retry backoff has elapsed at now (see SecretOutboxRetryDelay).
func (*Store) ListSecretPutOutboxBatch ¶ added in v0.6.1
func (s *Store) ListSecretPutOutboxBatch(ctx context.Context, limit int) ([]SecretPutOutboxRecord, error)
ListSecretPutOutboxBatch returns at most limit pending put fan-out jobs.
func (*Store) ListSecretPutOutboxDue ¶ added in v0.6.1
func (s *Store) ListSecretPutOutboxDue(ctx context.Context, now time.Time, limit int) ([]SecretPutOutboxRecord, error)
ListSecretPutOutboxDue is ListSecretPutOutboxBatch restricted to rows whose retry backoff has elapsed at now (see SecretOutboxRetryDelay).
func (*Store) ListSnapshotAliases ¶ added in v0.1.7
func (s *Store) ListSnapshotAliases(ctx context.Context, facade string) (map[string]models.SnapshotAlias, error)
ListSnapshotAliases returns all alias rows for the given facade keyed by alias. Pass empty facade to fetch every alias regardless of facade.
func (*Store) ListSnapshotAliasesForOwner ¶ added in v0.6.7
func (s *Store) ListSnapshotAliasesForOwner(ctx context.Context, facade, ownerRef string) (map[string]models.SnapshotAlias, error)
ListSnapshotAliasesForOwner is ListSnapshotAliases narrowed to aliases whose snapshot belongs to ownerRef. Owner-scoped callers use it so another tenant's alias rows (and the facade state on them) never leave the store.
func (*Store) ListSnapshotPage ¶ added in v0.6.7
func (s *Store) ListSnapshotPage(ctx context.Context, q SnapshotPageQuery) ([]SnapshotPageRow, error)
ListSnapshotPage returns one page of the catalogue. A snapshot with several aliases for the same facade still yields exactly one row (its smallest alias), so a page never holds duplicates.
func (*Store) ListSnapshots ¶ added in v0.1.7
func (*Store) ListSnapshotsPendingPushPage ¶ added in v0.6.12
func (s *Store) ListSnapshotsPendingPushPage(ctx context.Context, after SnapshotPushCursor, limit int) ([]*models.SandboxSnapshot, error)
ListSnapshotsPendingPushPage returns up to limit queued snapshots after the cursor: 'pending' (fresh from a create), 'error' (a failed attempt to retry) and 'pushing' whose claim has expired (a worker that died or hung). A backlog is read page by page rather than all at once, each page a range scan of the partial queue index, so a recovery storm costs memory in proportion to the page, not to the backlog.
func (*Store) ListTeamQuotas ¶ added in v0.6.12
ListTeamQuotas returns every team's quota, by team. The table holds one row per team an admin limited, so it is small.
func (*Store) ListTemplateInventoryIDs ¶ added in v0.6.1
func (s *Store) ListTemplateInventoryIDs(ctx context.Context) (readyIDs, catalogIDs []string, err error)
ListTemplateInventoryIDs returns both the ready-only placement inventory and the all-lifecycle administrative catalogue in one lightweight query. Keeping these sets distinct prevents a pending or failed template from looking absent to item routing without making it eligible for sandbox placement.
func (*Store) ListTemplates ¶ added in v0.4.1
func (*Store) ListTemplatesPendingPush ¶ added in v0.4.1
ListTemplatesPendingPush returns the templates the reconciler should retry: push_state IN ('pending', 'error'). 'pushing' is intentionally excluded so a row currently being processed by another reconciler tick is not re-claimed before its terminal state lands; a stale claim (older than PushClaimLease) is listed again. Claiming goes through ClaimTemplatePush, which is what actually keeps two workers apart.
The status precondition (must be ready) keeps half-built templates from sneaking into the push queue if someone manually flipped push_state. The reconciler enforces the same guard defensively, but filtering at the source means we never even materialize the row.
func (*Store) ListTemplatesReadyBefore ¶ added in v0.4.1
func (s *Store) ListTemplatesReadyBefore(ctx context.Context, cutoff time.Time) ([]*models.Template, error)
ListTemplatesReadyBefore returns the `ready` templates whose `ready_at` is older than the cutoff. Used by the Phase 6 PR-E rotation reconciler to find rebuild candidates. Only `ready` (not `ready_no_snapshot`) qualifies — rotating a ready_no_snapshot row would just re-burn build budget without delivering the rotation's goal (refreshing the snapshot's kernel + toolbox bytes).
Returns rows sorted oldest-first so a reconcile sweep that hits its per-tick fanout cap rotates the most-overdue templates first.
func (*Store) ListUnhealthyTemplates ¶ added in v0.4.1
ListUnhealthyTemplates returns every template row sitting in status='unhealthy'. The daemon-start scanner in service.RekickUnhealthyTemplatesAtStart sweeps this list once at boot and kicks RebuildTemplateSnapshot for each row, closing the crash-mid-rebuild gap: if sandboxd died after MarkTemplateUnhealthy flipped the row but before the in-process kicker finished, the row would otherwise be stuck unhealthy forever — every create against that template would fail with a confusing "template unhealthy" error and only operator intervention would resolve it.
Mirrors ListTemplatesPendingPush in shape (same SELECT projection, different WHERE) so the scan path is uniform with the existing push reconciler. No status precondition beyond status='unhealthy' itself — the rebuild path inside RebuildTemplateSnapshot re-checks the row under its own read, so a row that another caller already recovered between this list and the rebuild kick is handled cleanly.
func (*Store) ListVolumeAttachmentsForSandbox ¶ added in v0.6.12
func (s *Store) ListVolumeAttachmentsForSandbox(ctx context.Context, sandboxID string) ([]models.VolumeAttachment, error)
ListVolumeAttachmentsForSandbox returns the platform-volume attachments sandboxID holds, through idx_volume_attachments_sandbox. A destroy reads them before the sandbox row goes (the FK cascade removes them with it) to find the delete_with_sandbox volumes it may be the last user of. Never nil.
func (*Store) ListVolumes ¶ added in v0.5.4
ListVolumes returns all volumes owned by tenant, newest first. Empty result is a zero-length slice, never nil.
func (*Store) ListWarmPools ¶ added in v0.6.12
ListWarmPools returns every entry by image. There are at most models.MaxWarmPools, so there is no paging.
func (*Store) ListWasmCheckpointPushes ¶ added in v0.5.3
func (s *Store) ListWasmCheckpointPushes(ctx context.Context, sandboxID string) ([]WasmCheckpointPushRecord, error)
ListWasmCheckpointPushes returns every push history row for a sandbox id, across ALL of its incarnations, newest-first. It is for the terminal destroy path, where the id itself is going away; retention must use ListWasmCheckpointPushesForIncarnation instead.
func (*Store) ListWasmCheckpointPushesForIncarnation ¶ added in v0.6.1
func (s *Store) ListWasmCheckpointPushesForIncarnation(ctx context.Context, sandboxID, incarnationID string) ([]WasmCheckpointPushRecord, error)
ListWasmCheckpointPushesForIncarnation returns ONE lifetime's pushes, newest-first — the set keep-last-N retention is allowed to count and prune.
Retention used to count every push for the sandbox id. Pushes are detached with a multi-minute budget, so a destroyed incarnation's pushes can finish after the id was re-created; ordered by completion time they then displaced the replacement's checkpoint from its own retention window, and retention deleted the manifest the live row still pointed at.
func (*Store) ListWasmModules ¶ added in v0.5.3
func (s *Store) ListWasmModules(ctx context.Context) ([]WasmModuleRecord, error)
ListWasmModules returns all catalogue rows, every namespace, newest-first. Callers filter by owner; the same id may appear once per namespace.
func (*Store) ListWasmModulesOlderThan ¶ added in v0.5.3
func (s *Store) ListWasmModulesOlderThan(ctx context.Context, cutoff time.Time) ([]WasmModuleRecord, error)
ListWasmModulesOlderThan returns catalogue rows not updated since cutoff.
func (*Store) ListWasmStateKVKeys ¶ added in v0.5.3
ListWasmStateKVKeys lists keys for a sandbox.
func (*Store) LiveVolumeExistsForSource ¶ added in v0.5.4
LiveVolumeExistsForSource reports whether any current volume row resolves to source. The reclaim worker calls this before deleting backend bytes: because sources are deterministic, a delete-then-recreate of the same name produces a new volume row pointing at the same coordinate. When that live row exists the worker must NOT delete the bytes — they now belong to the recreated volume — and simply drops the stale ledger row instead.
func (*Store) MarkContainerNetnsSlotRealized ¶ added in v0.5.6
func (s *Store) MarkContainerNetnsSlotRealized(ctx context.Context, sandboxID, netnsPath, containerIP string, now time.Time) (*ContainerNetnsSlot, error)
MarkContainerNetnsSlotRealized records CNI ADD output for a reserved slot. Idempotent when already realized or adopted with the same paths.
func (*Store) MarkContainerNetnsSlotReleasing ¶ added in v0.6.9
func (s *Store) MarkContainerNetnsSlotReleasing(ctx context.Context, slotID, owner, netnsPath, containerIP string, now time.Time) error
MarkContainerNetnsSlotReleasing parks a slot whose host teardown failed: owner cleared, state releasing, netns_path / container_ip set to the identity the teardown used so a retry deletes the same CNI state. owner is the sandbox_id the caller saw ("" for a row with no owner); the update only applies while the row still has that owner, so a stale caller can never park a slot that was meanwhile freed and handed to another sandbox. Returns ErrNotFound when the row no longer matches.
func (*Store) MarkFirecrackerVMMSlotFailed ¶ added in v0.4.1
func (s *Store) MarkFirecrackerVMMSlotFailed(ctx context.Context, slotID, errMsg string, now time.Time) error
MarkFirecrackerVMMSlotFailed records that the spawner could not produce a paused-and-loaded VMM for this slot and moves the row directly to 'released' so the GC sweep cleans it up after the TTL. Skipping the 'loaded' intermediate is intentional: a failed slot was never claimable, and a transient 'loaded' state on a row whose VMM is actually missing would let the next Allocate hand out a dead process. last_error is preserved on the row for operator triage.
func (*Store) MarkFirecrackerVMMSlotLoaded ¶ added in v0.4.1
func (s *Store) MarkFirecrackerVMMSlotLoaded(ctx context.Context, slotID, apiSocket, runDir string, vsockCID uint32, now time.Time) error
MarkFirecrackerVMMSlotLoaded flips 'spawning' → 'loaded' and stamps the per-slot artifact paths the allocator will hand to the sandbox create path. The WHERE clause asserts the current state so a retried call (or a racing GC) can't accidentally walk a slot backwards from 'allocated' to 'loaded'. apiSocket and runDir live in the row so PR 4-B's runtime adapter can adopt a pre-spawned firecracker process across daemon restarts without re-deriving them.
func (*Store) MarkNetworkQuotaExceeded ¶ added in v0.1.7
func (s *Store) MarkNetworkQuotaExceeded(ctx context.Context, id string, detectedAt time.Time) error
MarkNetworkQuotaExceeded flips the flag on. detectedAt records when the crossover was first observed so the API can surface it to the SDK. Calls when already-exceeded preserve the original detectedAt — the trigger time is the interesting one, not the most recent re-observation.
func (*Store) MarkRestarted ¶ added in v0.6.12
MarkRestarted records that a pending restart ran at at: nothing is pending any more, and at is what the next failure measures "ran fine for 10 minutes" from.
func (*Store) MarkSandboxRollbackPending ¶ added in v0.6.12
MarkSandboxRollbackPending records that the create of id failed and its rollback has not finished (models.Sandbox.RollbackPending). It only ever sets the flag: the row's delete is what ends it. ErrNotFound when there is no row, which for a rollback means there is nothing left to roll back.
func (*Store) MarkSecretDeleteOutboxPromoted ¶ added in v0.6.1
func (s *Store) MarkSecretDeleteOutboxPromoted(ctx context.Context, sandboxID, incarnationID string, generation int64) (promoted bool, err error)
MarkSecretDeleteOutboxPromoted makes a staged retirement eligible after the matching Raft generation is visible. The exact-generation fence prevents an old completion from releasing a newer staged transition. promoted=false means a concurrent writer replaced the row and the caller must reload it.
func (*Store) MarkTemplatePushPending ¶ added in v0.4.1
MarkTemplatePushPending is the kickTemplateBuild success-path seam for Phase 6 PR 6-B.1. Idempotent and state-guarded: the WHERE clause only flips rows whose push_state is currently "active", so a row that the reconciler is already working on (pending|pushing) is left alone. push_error is cleared because a freshly-built artifact is a fresh attempt — any prior failure no longer applies.
Returns (true, nil) when the row moved, (false, nil) when the row did not exist OR was already pending/pushing/error. Callers can gate their reconciler-kick on changed=true so a no-op transition doesn't fire an extra reconciler tick.
func (*Store) MarkTemplateUnhealthy ¶ added in v0.4.1
MarkTemplateUnhealthy is the Phase 6 PR-A transition for "snapshot was ready, now corrupt at load time". The WHERE status='ready' guard is the idempotency primitive: many concurrent Creates can hit the same corrupt snapshot in a burst, and only the first call's UPDATE affects a row — subsequent calls return (false, nil). Callers gate the async rebuild kick on changed=true so exactly one rebuild fires per corruption event.
has_snapshot is cleared in the same row update so the resolver and the warm-pool lister both see HasSnapshot=false on the next read — the cold-boot fallback fires until the rebuild succeeds. The snapshot artifact paths are kept on the row for forensic inspection; the rebuild overwrites them in place.
snapshot_error captures the corruption reason for operator-facing surfaces (the GET /v1/templates/{id} payload, future runbooks). The status itself is the alertable signal; the message is the human-readable detail.
func (*Store) NextClusterSecretSealGenerationForIncarnation ¶ added in v0.6.1
func (s *Store) NextClusterSecretSealGenerationForIncarnation(ctx context.Context, sandboxID, incarnationID string) (int64, error)
NextClusterSecretSealGenerationForIncarnation allocates within one sandbox lifecycle. Generations are authenticated together with incarnation_id, so a stale row or tomb from a reused sandbox ID must not force or block the new lifecycle's sequence.
func (*Store) ProfileReferences ¶ added in v0.6.6
func (s *Store) ProfileReferences(ctx context.Context) ([]ProfileRef, error)
ProfileReferences returns every live sandbox's profile references, for the re-apply pass and its applied generations. It reads the index, not the sandboxes it joins only to drop destroyed rows.
func (*Store) PruneClusterSecretTombs ¶ added in v0.6.1
func (s *Store) PruneClusterSecretTombs(ctx context.Context, cutoff time.Time, limit int) (int64, error)
PruneClusterSecretTombs removes a bounded batch of expired delete fences. A tomb is eligible only after the durable peer-delete outbox is fully ACKed and no local sandbox or sealed row can still use the ID. The retention window is deliberately much longer than every fan-out request deadline, preventing an indefinitely delayed stale PUT from resurrecting deleted credentials while keeping cardinality bounded for UUID sandbox IDs. Peer PUT ingress additionally requires a matching live Raft placement, which remains the anti-resurrection fence after an eligible tomb is pruned.
func (*Store) PruneSandboxAuditACL ¶ added in v0.6.1
PruneSandboxAuditACL removes post-delete authorization metadata after its audit retention window. For a reused live sandbox ID, only its newest ACL is protected; older incarnations remain retention-bounded instead of surviving forever merely because a different lifecycle currently owns the same ID.
func (*Store) PutClusterSecret ¶ added in v0.2.1
PutClusterSecret upserts a sealed row and returns the seal_generation that landed. The caller must allocate the generation before sealing because it is authenticated inside the envelope; synthesizing one here would make the row identity disagree with its ciphertext binding.
func (*Store) PutDeletedSandboxView ¶ added in v0.6.7
func (s *Store) PutDeletedSandboxView(ctx context.Context, sandboxID, facade, ownerRef, viewJSON string, now time.Time) error
PutDeletedSandboxView records (or replaces) the terminal view for a deleted sandbox. There is no sandbox row to key against — the point is to answer after the row is gone — so this is a plain upsert on (sandbox_id, facade).
func (*Store) PutEgressProfile ¶ added in v0.6.6
func (s *Store) PutEgressProfile(ctx context.Context, owner, name string, allowOut []string, description string, now time.Time) (p models.EgressProfile, changed bool, err error)
PutEgressProfile creates or replaces an owner's profile. Generation goes up by one only when the entries or description change, so the same body twice is a no-op; changed reports whether it did.
func (*Store) PutEnv ¶ added in v0.6.1
PutEnv stores an encrypted env blob for a sandbox (opaque to the store).
func (*Store) PutIdentityRole ¶ added in v0.6.12
func (s *Store) PutIdentityRole(ctx context.Context, owner, tag, minRole string, now time.Time) (models.IdentityRole, bool, error)
PutIdentityRole puts a tag on an owner's allow list, or changes its minimum role. The same body twice is a no-op; changed reports whether it wrote.
func (*Store) PutMounts ¶
PutMounts stores an encrypted mount blob for a sandbox. The blob is opaque to the store layer; encryption / decryption happens in the service layer.
func (*Store) PutNodeStorageRetirement ¶ added in v0.6.1
func (s *Store) PutNodeStorageRetirement(ctx context.Context, nodeID, actor, reason string, attestedAt time.Time) error
PutNodeStorageRetirement records (or re-records) an attestation. Idempotent by node id: re-attesting moves attested_at forward, which widens the set of covered obligations to those that existed at the new attestation time and never narrows it.
func (*Store) PutSandboxIdentity ¶ added in v0.6.12
func (s *Store) PutSandboxIdentity(ctx context.Context, row SandboxIdentity) error
PutSandboxIdentity records a new sandbox's identity, or replaces it (a recreate with the same id), clearing the token state.
func (*Store) PutTeamQuota ¶ added in v0.6.12
func (s *Store) PutTeamQuota(ctx context.Context, team string, limits models.TeamQuotaRequest, now time.Time) (q models.TeamQuota, changed bool, err error)
PutTeamQuota creates or replaces a team's quota. Generation goes up only when a limit changes, so the same body twice is a no-op; changed says whether it did.
func (*Store) PutVolumeAttachments ¶ added in v0.5.4
func (s *Store) PutVolumeAttachments(ctx context.Context, attachments []models.VolumeAttachment) error
PutVolumeAttachments upserts the platform-volume attachments for a sandbox. The volume_id and sandbox_id foreign keys make create/delete races explicit: if a volume is deleted before the sandbox can persist its attachment, the insert fails and the service rolls the sandbox create back.
func (*Store) PutWarmPool ¶ added in v0.6.12
func (s *Store) PutWarmPool(ctx context.Context, in models.WarmPool, now time.Time) (p models.WarmPool, changed bool, err error)
PutWarmPool creates or replaces the entry for an image. Generation goes up by one only when the settings change, so the same body twice is a no-op; changed reports whether it did. The limit is checked in the same transaction as the insert, so two concurrent creates cannot both pass it.
func (*Store) PutWasmStateKV ¶ added in v0.5.3
PutWasmStateKV upserts one durable host-KV row (§4.6).
func (*Store) ReadIdentityKeys ¶ added in v0.6.12
ReadIdentityKeys returns the signing key set; generation 0 with no keys before the first key is made.
func (*Store) ReadSecretAuditIndex ¶ added in v0.6.1
func (s *Store) ReadSecretAuditIndex(ctx context.Context, key SecretAuditIndexKey, minTime int64) (SecretAuditIndexMeta, []SecretAuditIndexChunk, bool, error)
ReadSecretAuditIndex returns the posting-list chunks a page for key may need, plus the meta they are consistent with, in one snapshot. An empty IncarnationID matches every lifecycle of the sandbox. Gap-marker chunks (empty sandbox id) are always included because every page must surface them. Chunks whose newest entry is older than minTime cannot contribute to a page after that cursor and are skipped in SQL.
func (*Store) ReassignContainerNetnsSandbox ¶ added in v0.5.6
func (s *Store) ReassignContainerNetnsSandbox(ctx context.Context, fromSandboxID, toSandboxID string, now time.Time) error
ReassignContainerNetnsSandbox moves adopted slot ownership from one sandbox id to another (warm park → adopt). Idempotent when toSandboxID already owns.
func (*Store) RecordIdentityTokenFailed ¶ added in v0.6.12
RecordIdentityTokenFailed notes why a push failed; the token state is left as it was, so the next pass still finds the row due.
func (*Store) RecordIdentityTokenPushed ¶ added in v0.6.12
func (s *Store) RecordIdentityTokenPushed(ctx context.Context, id, kid string, expires time.Time) error
RecordIdentityTokenPushed notes the token now in the sandbox.
func (*Store) RecordProgramExit ¶ added in v0.6.12
func (s *Store) RecordProgramExit(ctx context.Context, id string, runGeneration int64, at time.Time, exitCode int) (bool, error)
RecordProgramExit stores the end of a started sandbox's main program: when it ended, status_reason program_exited and its exit code. Only the first report counts (program_exited_at must still be NULL), only while the row is started, and only for the run the report was read from (runGeneration, the row's run_generation when the caller asked toolboxd). A sandbox that stopped meanwhile is left alone, and so is one that stopped and started again: its new run has a new generation, so the old run's exit cannot land on it. recorded reports whether this call stored it.
func (*Store) RefreshPendingImageGCIfExists ¶ added in v0.3.1
func (s *Store) RefreshPendingImageGCIfExists(ctx context.Context, image string, at time.Time) (bool, error)
RefreshPendingImageGCIfExists pushes the row's scheduled_at forward when (and only when) a row for image is already present. The Create path calls this after store.Create succeeds, so a freshly-used image that previously had a pending GC gets its deadline reset from "now" instead of inheriting the original destroy's old timestamp.
UPDATE-only (not UPSERT) on purpose: a row should only ever exist when a destroy has scheduled an image for cleanup. We do NOT want the create path inserting one — that would turn pending_image_gc into a one-row-per-image-ever-used table. The row-count stays bounded by "images destroyed in the last TTL window". Returns whether a row was touched, so callers can distinguish "deadline pushed forward" from "no pending GC, nothing to push". Refreshes every engine's row for the image: a create that uses the image keeps it alive wherever it is cached, and the janitor is the only thing that removes rows.
func (*Store) ReleaseContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) ReleaseContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) error
ReleaseContainerNetnsSlot returns a slot to the free pool. Idempotent.
func (*Store) ReleaseFirecrackerTapSlot ¶ added in v0.4.1
ReleaseFirecrackerTapSlot returns a sandbox's slot to the pool by clearing sandbox_id + allocated_at. Idempotent: releasing a sandbox that owns no slot is a no-op.
func (*Store) ReleaseFirecrackerVMMSlot ¶ added in v0.4.1
func (s *Store) ReleaseFirecrackerVMMSlot(ctx context.Context, sandboxID string, now time.Time) error
ReleaseFirecrackerVMMSlot moves a sandbox's slot from 'allocated' to 'released'. Idempotent in two senses: releasing a sandbox that never owned a slot is a no-op (RowsAffected=0 returns nil), and releasing a slot already in 'released' is a no-op for the same reason. The WHERE-on-status keeps a malformed retry from resurrecting a slot that the spawner failed and already marked released.
func (*Store) ReleaseOrphanedFirecrackerVMMSlots ¶ added in v0.4.1
ReleaseOrphanedFirecrackerVMMSlots marks any warm-pool slot left in 'spawning' or 'loaded' with no sandbox claim as 'released'. The daemon calls this once at startup before refilling so rows stranded by the previous process do not stay invisible to GC forever.
func (*Store) ReleaseSnapshotPush ¶ added in v0.6.12
func (s *Store) ReleaseSnapshotPush(ctx context.Context, ownerRef, name string, claimedAt time.Time, state, errMsg string) (bool, error)
ReleaseSnapshotPush ends a claim without a registry copy: state 'error' (with the reason, retried next sweep) or 'active' (nothing to push). Fenced exactly like CompleteSnapshotPush.
func (*Store) ReleaseTemplatePush ¶ added in v0.6.12
func (s *Store) ReleaseTemplatePush(ctx context.Context, id string, claimedAt time.Time, state, errMsg string) (bool, error)
ReleaseTemplatePush is ReleaseSnapshotPush for templates.
func (*Store) RemoveCustomDomain ¶ added in v0.3.1
RemoveCustomDomain deletes the (sandbox, hostname) row. Cross-sandbox removal is rejected — the API gets ErrNotFound rather than silently stealing a hostname from another sandbox.
func (*Store) ResealSealedRows ¶ added in v0.6.9
func (s *Store) ResealSealedRows(ctx context.Context, col SealedColumn, rows []ResealedRow) (written []bool, err error)
ResealSealedRows writes a page of resealed values in one transaction, each under compare-and-swap on the exact bytes read: a write, a reseal or a delete that landed in between wins and the row is skipped. written[i] says whether rows[i] was stored.
func (*Store) ReserveContainerNetnsSlot ¶ added in v0.5.6
func (s *Store) ReserveContainerNetnsSlot(ctx context.Context, sandboxID string, now time.Time) (*ContainerNetnsSlot, error)
ReserveContainerNetnsSlot claims a free slot for sandboxID. Idempotent when sandboxID already owns a slot. Returns ErrNoFreeContainerNetnsSlot only when no free slot is left: never because another create was claiming at the same moment (see claimContainerNetnsSlot).
func (*Store) ResetContainerNetnsSlotToFree ¶ added in v0.5.6
func (s *Store) ResetContainerNetnsSlotToFree(ctx context.Context, slotID string, now time.Time) error
ResetContainerNetnsSlotToFree clears a slot row back to the empty free state.
func (*Store) ResetSecretAuditIndex ¶ added in v0.6.1
func (s *Store) ResetSecretAuditIndex(ctx context.Context, meta SecretAuditIndexMeta) error
ResetSecretAuditIndex drops every posting list and pins meta to the start of a (re)build. The caller then streams the file back in with WriteSecretAuditIndex.
func (*Store) ResolveCustomDomain ¶ added in v0.3.1
ResolveCustomDomain is the hot path for the TLSAsk handler — single PK lookup, no scan. Returns ErrNotFound for unknown hostnames so the handler can fold it into a 403 without an error log on the success path. We do not surface target_port here because the routing dial target is already baked into the per-domain Caddy route at install time (see IngressCustomDomainHTTPRouteID); TLSAsk only needs the ownership signal.
func (*Store) ResolveSandboxIDByName ¶ added in v0.1.7
ResolveSandboxIDByName returns the ID of ownerRef's sandbox called name, or ErrNotFound if no row matches. Names are unique per owner (idx_sandboxes_name), and ownerRef "" is the operator namespace, so at most one row matches. Empty input is rejected so an accidental "" lookup does not match a no-name sandbox via the partial unique index's escape hatch.
func (*Store) ResolveWasmModule ¶ added in v0.6.8
func (s *Store) ResolveWasmModule(ctx context.Context, ownerRef, id string) (WasmModuleRecord, error)
ResolveWasmModule returns ownerRef's own row for id, else the operator-published ("") row for id: the order reads and create-time boots resolve a catalogue id in. An own row wins even when it is not ready, so a failed registration never silently boots the operator's different bytes. One statement (two probes of the (owner_ref, id) key) so the create-time lookup costs the same single query it did before ids were per owner.
func (*Store) RetireClusterSecretGeneration ¶ added in v0.6.1
func (s *Store) RetireClusterSecretGeneration(ctx context.Context, sandboxID, incarnationID string, generation int64) error
RetireClusterSecretGeneration removes only the generation observed by an authoritative GC scan. It creates no peer-delete obligation: supersession of this replica is not authority to delete the promoted recovery copies.
func (*Store) RevokeSandboxTokens ¶ added in v0.6.12
RevokeSandboxTokens moves the sandbox's tokens_not_before forward to notBefore and returns the value the row now holds. It never moves it back: a second revoke with an older clock reading, or a retry, keeps the later value, so a repeated call can only refuse more tokens, never bring one back. updated_at is left alone, as nothing a caller reads about the sandbox changed. Returns ErrNotFound if no row matches id.
func (*Store) RewrapClusterSecret ¶ added in v0.6.9
func (s *Store) RewrapClusterSecret(ctx context.Context, ref string, generation int64, old, rewrapped []byte) (bool, error)
RewrapClusterSecret replaces a row's sealed bytes with a rewrap of them, only if the row still has the generation and the bytes the caller read (compare-and-swap): a reseal, a delete or a newer peer copy that landed in between wins, and the caller skips the row. A rewrap must keep the content; anything else is refused.
func (*Store) RollbackSandboxCreate ¶ added in v0.6.1
RollbackSandboxCreate removes a sandbox that never completed its create transaction together with only its explicit audit-incarnation row inserted by Create. Older incarnation rows may belong to a previously deleted sandbox that reused the same deterministic ID; deleting them would create a retained evidence authorization vacuum. A normal Delete intentionally retains the current row.
func (*Store) SandboxAuditIncarnations ¶ added in v0.6.1
func (s *Store) SandboxAuditIncarnations(ctx context.Context, ids []string) (map[string]string, error)
SandboxAuditIncarnations returns the live lifecycle of every listed sandbox that has a row, in a handful of round trips. A standalone node has no Raft placement to say which sealed rows are still someone's; this is its authority: a sealed row whose (sandbox, incarnation) is not here is orphaned.
func (*Store) SandboxIDsClaimingContainerIP ¶ added in v0.6.6
SandboxIDsClaimingContainerIP returns every sandbox that may be using ip right now: a creating or started sandbox row carrying it, or a claimed container netns slot holding it. The slot side matters because a pooled netns is claimed (and its rules installed) before the new sandbox's row is persisted. Event-driven rule clears skip when any claimant other than the event's own sandbox exists (egress plan P0-6).
func (*Store) SandboxIdentitiesDue ¶ added in v0.6.12
func (s *Store) SandboxIdentitiesDue(ctx context.Context, cutoff time.Time, after IdentityDueCursor, limit int) ([]SandboxIdentity, error)
SandboxIdentitiesDue returns up to limit running sandboxes whose token expires before cutoff (or that have none yet), soonest first, after the cursor: the refresher's work list. It walks the expiry index, then joins each row's sandbox for its status.
func (*Store) SandboxesReferencingProfile ¶ added in v0.6.6
func (s *Store) SandboxesReferencingProfile(ctx context.Context, owner, name string) ([]ProfileRef, error)
SandboxesReferencingProfile returns the live sandboxes that reference an owner's profile, by index probe.
func (*Store) SchedulePendingImageGC ¶ added in v0.3.1
func (s *Store) SchedulePendingImageGC(ctx context.Context, engine, image string, at time.Time) error
SchedulePendingImageGC records (or refreshes) a pending image-deletion row for one engine's copy of an image. UPSERT on the (engine, image) PK means concurrent or repeated destroys collapse to one row and the TTL clock restarts from the most recent destroy — so a busy churn pattern on the same image keeps deferring removal instead of racing the janitor. Empty image is a no-op; empty engine means "this host's configured engine".
func (*Store) SchedulePendingVolumeDeletion ¶ added in v0.5.4
func (s *Store) SchedulePendingVolumeDeletion(ctx context.Context, v models.Volume, source string) error
SchedulePendingVolumeDeletion writes (or refreshes) the durable reclaim-ledger row for a volume whose metadata row lives outside this SQLite store (the cluster-FSM path), so the per-node reclaim worker still has the coordinates to delete the S3 prefix / NFS dir. The single-node path uses DeleteVolumeIfUnattached, which does this in one transaction with the row delete; this is the split-store equivalent.
func (*Store) ScheduleRestart ¶ added in v0.6.12
ScheduleRestart records a pending restart on failure: the consecutive failure count the backoff was computed from and when the restart is due.
func (*Store) ScheduleSnapshotRegistryRetirement ¶ added in v0.6.12
func (s *Store) ScheduleSnapshotRegistryRetirement(ctx context.Context, r SnapshotRegistryRetirement) error
ScheduleSnapshotRegistryRetirement records a retirement obligation. An obligation already recorded for the same manifest is left as it is.
func (*Store) SecretAuditIndexStats ¶ added in v0.6.1
SecretAuditIndexStats reports chunk and entry totals for observability and tests.
func (*Store) SecretDeleteOwedByRecipient ¶ added in v0.6.1
SecretDeleteOwedByRecipient counts, per peer node, the outbox rows that still owe that peer a delete. It is the owner's current snapshot for the UC-160 storage-obligation report: the leader REPLACES the previous report with it, so this must describe the whole outbox, not a delta.
Recipients are counted in Go rather than with SQLite's json_each so the store takes no dependency on the JSON1 build of the driver. The outbox only holds pending deletes, so it stays small.
func (*Store) SecretLifecycleStats ¶ added in v0.6.1
func (s *Store) SecretLifecycleStats(ctx context.Context) (SecretLifecycleStats, error)
func (*Store) SeedContainerNetnsSlot ¶ added in v0.5.6
SeedContainerNetnsSlot inserts one free pool row. Idempotent on slot_id PK.
func (*Store) SeedFirecrackerTapSlot ¶ added in v0.4.1
func (s *Store) SeedFirecrackerTapSlot(ctx context.Context, slot FirecrackerTapSlot, now time.Time) error
SeedFirecrackerTapSlot inserts one slot row into the pool. Idempotent: the tap_name PRIMARY KEY makes re-seeding with the same name a no-op, so the daemon's boot path can call this for every configured slot without coordinating across restarts. Two distinct slots with the same vsock_cid would trip the unique index — callers must precompute non-colliding CIDs (the wrapper in internal/network/tap does this).
func (*Store) SetAllowPublicTraffic ¶ added in v0.5.5
func (s *Store) SetAllowPublicTraffic(ctx context.Context, id string, allow bool, publicURL string) error
SetAllowPublicTraffic flips the public-exposure flag together with the derived public_url in one statement. The expose_port opt-in path (the only way a private sandbox becomes public after create) is the caller; the two columns must move atomically because every Get materializes both — a public row with an empty public_url (or the reverse) would misreport reachability. A dedicated setter rather than Upsert so the flip doesn't race the runtime-state machine on the rest of the row.
func (*Store) SetAutoImportPending ¶ added in v0.2.3
SetAutoImportPending toggles the AOCR auto-import retry flag. The post-pull auto-import path sets it to true on failure; the reconciler clears it after a successful import. The reconciler must call this rather than Upsert to avoid racing the runtime-state machine on the rest of the sandbox row.
func (*Store) SetCustomDomainStatus ¶ added in v0.3.1
func (s *Store) SetCustomDomainStatus(ctx context.Context, hostname string, status models.CustomDomainStatus, lastError string) error
SetCustomDomainStatus updates the per-domain state machine. Idempotent — repeated calls with the same (status, lastError) are still write-once on updated_at, which the caller may use as a heartbeat for "we saw an ask for this host". Returns ErrNotFound when the hostname is unknown so a caller observing an issuance failure for a since-removed host gets a clean signal.
func (*Store) SetEgressHold ¶ added in v0.6.6
SetEgressHold records the fail-closed hold and its reason (CEO D16). It is idempotent and keeps the original hold_since on a repeated hold.
func (*Store) SetEgressHoldRanked ¶ added in v0.6.6
func (s *Store) SetEgressHoldRanked(ctx context.Context, sandboxID, reason string, rank map[string]int, now time.Time) error
SetEgressHoldRanked records a hold unless the sandbox already has a stronger one: rank maps each reason to its strength (unknown is 0), and a reason is only replaced by one at least as strong, in one statement, so a weaker hold racing a stronger one can't overwrite it.
func (*Store) SetEgressProfilesApplied ¶ added in v0.6.6
func (s *Store) SetEgressProfilesApplied(ctx context.Context, id string, applied []models.EgressProfileRef) error
SetEgressProfilesApplied records which generation of each referenced profile is live on a sandbox, after a successful apply.
func (*Store) SetFleetSuspended ¶ added in v0.5.1
SetFleetSuspended flips the fleet-suspend marker on a sandbox. The enforcement loop sets it true when a standing=suspend directive stops a running sandbox, and clears it on recovery so only fleet-suspended sandboxes are auto-restarted (a user/operator stop is left alone). Idempotent: writing the same value twice is a harmless no-op UPDATE. Returns ErrNotFound if the row is gone (already deleted), which callers treat as success — there is nothing left to converge.
func (*Store) SetIdempotentRequestTarget ¶ added in v0.6.7
func (s *Store) SetIdempotentRequestTarget(ctx context.Context, scope, fingerprint, targetID string, now time.Time) error
SetIdempotentRequestTarget records target on a row that is still pending, leaving it pending. A claimer whose work has produced its result but still owes follow-up (the Runloop ledger: a finished command whose session is not deleted yet) stores the result here first, so neither a crash nor a lost cache can lose it, and moves the row to ready with CompleteIdempotentRequest once nothing is owed. A row that is no longer pending is left alone and reported as ErrNotFound.
func (*Store) SetInstalledEgress ¶ added in v0.6.6
func (s *Store) SetInstalledEgress(ctx context.Context, sandboxID string, inst InstalledEgress, now time.Time) error
SetInstalledEgress records the host enforcement that may now be in place for a sandbox.
func (*Store) SetNetworkLimits ¶ added in v0.1.7
func (s *Store) SetNetworkLimits(ctx context.Context, id string, bytesInLimit, bytesOutLimit int64) error
SetNetworkLimits replaces the per-sandbox network byte caps. Zero means unlimited; negative values are rejected. The handler validates first so the store does not re-validate. Returns ErrNotFound if no row matches id.
func (*Store) SetPendingEgressRuleClear ¶ added in v0.6.6
func (s *Store) SetPendingEgressRuleClear(ctx context.Context, p PendingEgressRuleClear, now time.Time) error
SetPendingEgressRuleClear records what is left at p's IP after a clear: p replaces the entry, and an empty p deletes it.
func (*Store) SetSandboxEgressProfiles ¶ added in v0.6.6
func (s *Store) SetSandboxEgressProfiles(ctx context.Context, id string, p NetworkPolicyWrite) error
SetSandboxEgressProfiles records a new sandbox's profile references and inline list; the create path calls it right after the row is written.
func (*Store) SetSecretCipher ¶ added in v0.6.1
SetSecretCipher configures at-rest toolbox-token sealing. Production wiring always supplies it; a missing cipher fails any token-bearing write or sealed token read rather than falling back to plaintext.
func (*Store) SetStatusReason ¶ added in v0.6.12
SetStatusReason records why a sandbox is in its status when the status itself does not change: a failover recreate, a restart on failure, or a main program that ended while the sandbox stays up. Upsert keeps the reason on a write that keeps the status, so these need their own write.
func (*Store) SetStatusReasonIfStatus ¶ added in v0.6.12
func (s *Store) SetStatusReasonIfStatus(ctx context.Context, id string, status models.SandboxStatus, reason string, exitCode *int) (bool, error)
SetStatusReasonIfStatus is SetStatusReason for a row that is still in status. A reason that explains a status must not land on a row another writer has moved since: a restart's "restarted" on a sandbox whose die event already wrote "crashed" would hide the crash its restart on failure answers. set reports whether the row was written (false for a row that moved, or is gone).
func (*Store) SetWakeArmed ¶ added in v0.2.4
SetWakeArmed toggles the wake_armed flag and bumps updated_at. The flag is set when the sandbox stops in a way that should auto-resume on the next inbound HTTP request (lifecycle idle / involuntary exit, both while Lifecycle.Serverless is true). It is cleared on a manual stop and after a successful wake. Returns ErrNotFound if no row matches id.
This is a dedicated setter rather than going through Upsert so the stop-event path and wake completion don't race the rest of the runtime state on the row (status, container_id, container_ip, etc.).
func (*Store) ShiftSecretAuditIndex ¶ added in v0.6.1
func (s *Store) ShiftSecretAuditIndex(ctx context.Context, floor, delta int64, meta SecretAuditIndexMeta) error
ShiftSecretAuditIndex re-bases the index after retention rewrote the file. Retention drops a byte prefix (floor) and prepends one checkpoint line, so every surviving offset moves by the same delta: chunks entirely below the floor are deleted, the one chunk per list that straddles it is trimmed, and the rest are shifted in place. This is O(chunks), never O(events), and it is why prune does not have to rebuild the index from the kept lines.
func (*Store) SnapshotRegistryCopyInUse ¶ added in v0.6.12
func (s *Store) SnapshotRegistryCopyInUse(ctx context.Context, registryRef, digest, ownerRef, name string) (inUse, pushPending bool, err error)
SnapshotRegistryCopyInUse answers the two questions asked before a copy is retired. inUse: a snapshot row on this node still names this exact manifest (ref and digest) — the obligation is void. pushPending: a row of the same owner and name has a push still to land (pending, pushing or error), which can put this very digest back under the tag — wait for it.
func (*Store) TeamQuotaSandboxes ¶ added in v0.6.12
TeamQuotaSandboxes lists an owner's sandboxes that are not destroyed, with the size each asked for. It is the single-node ledger's source of truth, read only when the ledger (re)loads an owner, never per create.
func (*Store) TouchSecretDeleteOutbox ¶ added in v0.6.1
func (s *Store) TouchSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, generation int64) error
TouchSecretDeleteOutbox moves a row to the back of the fair queue without counting an attempt: nothing was tried because the world was not ready (the placement could not be read, or a staged reseal is not yet promoted). The row stays due on the next tick.
func (*Store) TouchSecretPutOutbox ¶ added in v0.6.1
func (s *Store) TouchSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64) error
TouchSecretPutOutbox moves a row to the back of the fair queue without counting an attempt; see TouchSecretDeleteOutbox.
func (*Store) TransferFirecrackerTapSlot ¶ added in v0.5.5
func (s *Store) TransferFirecrackerTapSlot(ctx context.Context, fromID, toID string, now time.Time) (*FirecrackerTapSlot, error)
TransferFirecrackerTapSlot re-keys an allocated TAP slot from one owner id to another without changing the TAP name, IPs, or vsock CID. The warm-VMM pool uses this when a parked slot id becomes a real sandbox id. Retrying the same transfer is idempotent once toID owns the slot; trying to overwrite a different target slot fails before the UPDATE hits the partial unique index.
func (*Store) TryReserveHostPort ¶ added in v0.1.4
func (s *Store) TryReserveHostPort(ctx context.Context, sandboxID string, containerPort, hostPort int, protocol, publicURL string, now time.Time) (ReserveHostPortResult, error)
TryReserveHostPort attempts to claim hostPort for (sandboxID, containerPort) in a single INSERT OR IGNORE. The OR IGNORE swallows two distinct UNIQUE failures — the (sandbox_id, port) primary key AND the partial index on host_port — so on a no-op insert we follow up with a SELECT to disambiguate. Without that disambiguation, retrying expose for an already-exposed port looks identical to a host_port collision and walks the whole allocator pool before failing with "exhausted".
func (*Store) UpdateLifecycle ¶
UpdateLifecycle replaces the lifecycle fields on a sandbox row (the four timers plus the serverless opt-in) and bumps updated_at. Other fields are untouched. Returns ErrNotFound if no row matches id. The caller must validate the Lifecycle first; the store does not re-validate (it would couple two layers for no gain). wake_armed is intentionally NOT touched here — it transitions on stop/wake events, not on lifecycle edits.
func (*Store) UpdateRuntime ¶
func (*Store) UpdateSecretDeleteOutboxRecipients ¶ added in v0.6.1
func (s *Store) UpdateSecretDeleteOutboxRecipients(ctx context.Context, sandboxID, incarnationID string, recipients []string, generation int64) error
UpdateSecretDeleteOutboxRecipients replaces the pending recipient list (ACK shrink). Empty recipients deletes the outbox row. generation fences the update so a concurrent reseal/delete cannot shrink a newer outbox job.
func (*Store) UpdateSecretPutOutboxRecipients ¶ added in v0.6.1
func (s *Store) UpdateSecretPutOutboxRecipients(ctx context.Context, sandboxID, incarnationID string, recipients []string, sealGeneration int64) error
UpdateSecretPutOutboxRecipients shrinks the pending recipient list after a partial ACK. Empty recipients deletes the row (identity-fenced).
func (*Store) UpdateStatus ¶
func (*Store) UpdateStatusWithReason ¶ added in v0.6.12
func (s *Store) UpdateStatusWithReason(ctx context.Context, id string, status models.SandboxStatus, lastError, reason string, exitCode *int) error
UpdateStatusWithReason is UpdateStatus for a path that also knows why the status changed (models.StatusReason*): one statement, so the row is never seen in its new status with the old reason.
func (*Store) UpdateTags ¶ added in v0.1.7
UpdateTags replaces sandboxes.tags_json on the row matching id and bumps updated_at. Used by facades that want to mutate the native tags field without round-tripping the entire sandbox struct through Upsert. Returns ErrNotFound if no row matches.
func (*Store) UpdateTemplateSnapshotFailed ¶ added in v0.4.1
UpdateTemplateSnapshotFailed records the snapshot-phase error and flips status to ready_no_snapshot. The rootfs columns are untouched — the caller has already populated them via UpdateTemplateStatus during the rootfs phase, and the cold-boot fallback still needs the rootfs path intact. has_snapshot stays 0 (column default) so readers correctly skip the snapshot-load path.
func (*Store) UpdateTemplateSnapshotReady ¶ added in v0.4.1
func (s *Store) UpdateTemplateSnapshotReady(ctx context.Context, id, memPath, statePath string, sizeBytes int64, checksum string, vsockCID uint32, hasOverlay bool) error
UpdateTemplateSnapshotReady is the terminal-success seam for the snapshot phase. Writes the snapshot artifact metadata and flips status=ready / has_snapshot=1 / has_overlay=hasOverlay in one UPDATE so a concurrent reader (CreateSandbox racing the build goroutine) never observes "status=ready but the snapshot fields are still zero". snapshot_error is unconditionally cleared so a retried build that finally succeeds doesn't carry a stale message. hasOverlay is true for every PR-B-built template (the snapshot capture path always includes the overlay placeholder); kept as a parameter so a future "snapshot without overlay" build profile (e.g. a tiny boot-only template) does not require a schema change.
func (*Store) UpdateTemplateStatus ¶ added in v0.4.1
func (s *Store) UpdateTemplateStatus(ctx context.Context, id string, status models.TemplateStatus, rootfsPath, lastError string, sizeBytes int64) error
UpdateTemplateStatus is the rootfs-phase seam the build goroutine uses to transition between pending / building_rootfs / ready / ready_no_snapshot / failed. rootfsPath, sizeBytes, and lastError are overwritten unconditionally (including to empty on the success path) so a retried build that succeeds doesn't have to remember to clear stale error text. ready_at is stamped on the ready and ready_no_snapshot transitions (both are terminal-and-usable states); the GC sweep treats "no ready_at" as "never finished building" and leaves the row alone for the build goroutine to finish or fail.
The snapshot phase uses UpdateTemplateSnapshotReady / Failed instead so the snapshot columns and the ready transition land in one row update — readers never observe "status=ready but has_snapshot=0".
func (*Store) UpdateWasmCheckpoint ¶ added in v0.5.3
func (s *Store) UpdateWasmCheckpoint(ctx context.Context, sandboxID, incarnationID, status, checkpointPath, cloneGen, lastError string) error
UpdateWasmCheckpoint persists passivation metadata on a sandbox row, fenced to the incarnation the checkpoint was taken for. An empty incarnation means the caller has no lifecycle to fence against (pre-incarnation rows) and the write applies by id alone.
func (*Store) UpdateWasmRegistryPush ¶ added in v0.5.3
func (s *Store) UpdateWasmRegistryPush(ctx context.Context, sandboxID, incarnationID, registryRef, digest string) (applied bool, err error)
UpdateWasmRegistryPush records the AOCR ref/digest after a durable checkpoint push. incarnationID fences the write to the lifecycle the push was started for: these pushes run detached with a multi-minute timeout, so one can land after its sandbox is destroyed and the id re-created. applied=false means the row moved on and the result belongs to a dead lifecycle.
func (*Store) UpsertAccountMapping ¶ added in v0.5.1
UpsertAccountMapping records (or refreshes) an identity resolved by the fleet control plane. first_seen is preserved across calls; last_seen advances to now. Idempotent by owner_ref PK. Open-source builds never call this (no validator resolves user tokens); managed builds call it at create time, not per request, to keep the auth hot path write-free.
func (*Store) UpsertCompatState ¶ added in v0.1.7
UpsertCompatState writes the facade-private state blob for (sandboxID, facade). stateJSON is opaque to the store — each facade defines its own schema inside it. created_at is preserved on update so list ordering stays stable.
func (*Store) UpsertPort ¶
func (*Store) UpsertSandboxAuditACL ¶ added in v0.6.1
func (s *Store) UpsertSandboxAuditACL(ctx context.Context, sandboxID, ownerRef, incarnationID string) error
UpsertSandboxAuditACL records the tenant OwnerRef for audit authorization after the sandbox row (and placement) are gone. Rows are incarnation-scoped.
func (*Store) UpsertSecretDeleteOutbox ¶ added in v0.6.1
func (s *Store) UpsertSecretDeleteOutbox(ctx context.Context, sandboxID, incarnationID string, recipients []string, generation int64) error
UpsertSecretDeleteOutbox journals deletion from recipients retired by a reseal without deleting or tombstoning the active local generation.
func (*Store) UpsertSecretDeleteOutboxCopiedAt ¶ added in v0.6.1
func (s *Store) UpsertSecretDeleteOutboxCopiedAt(ctx context.Context, sandboxID, incarnationID string, recipients []string, generation int64, copiedAt time.Time) error
UpsertSecretDeleteOutboxCopiedAt is UpsertSecretDeleteOutbox with the provenance of the copies being deleted. copiedAt is when THESE recipients received the ciphertext this job deletes — not when the job was written. The distinction is what lets a storage-retirement attestation discharge an obligation for a copy that existed before the disk was destroyed, while still refusing one for a copy handed to a reused node id afterwards. A zero copiedAt means "as of now".
func (*Store) UpsertSecretPutOutbox ¶ added in v0.6.1
func (s *Store) UpsertSecretPutOutbox(ctx context.Context, sandboxID, incarnationID string, sealGeneration int64, recipients []string) error
UpsertSecretPutOutbox persists remaining peer PUT targets when the in-memory create fan-out queue is saturated. Blob bytes are reloaded from cluster_secrets at reconcile time by sandbox_id + seal_generation.
Identity is (sandbox_id, incarnation_id, seal_generation). A lower seal_generation never overwrites a newer job; same gen+incarnation merges recipients. Other incarnations are independent cleanup obligations.
func (*Store) UpsertSnapshotAlias ¶ added in v0.1.7
UpsertSnapshotAlias maps a facade-shaped alternate identifier onto a native sandbox_snapshots row. created_at is preserved on update.
func (*Store) UpsertWasmModule ¶ added in v0.5.3
func (s *Store) UpsertWasmModule(ctx context.Context, rec WasmModuleRecord) error
UpsertWasmModule inserts or updates a wasm_modules catalogue row. The row is keyed by (rec.OwnerRef, rec.ID), so an upsert only ever rewrites a row in the record's own namespace and never another owner's row with the same id.
func (*Store) WasmCheckpointRefInUse ¶ added in v0.6.1
func (s *Store) WasmCheckpointRefInUse(ctx context.Context, sandboxID string, excludePushID int64, rowIncarnation, registryRef, digest string) (bool, error)
WasmCheckpointRefInUse reports whether deleting ref would take away a manifest the LIVE sandbox with this id still depends on. excludePushID is the row being cleaned up, so it does not protect itself.
Deleting a checkpoint ref resolves its tag and deletes the MANIFEST, which removes every tag pointing at that digest. So a ref is in use not only when the live row names it, but when anything the live lifetime keeps resolves to the same manifest:
- the rolling :latest tag is shared by every incarnation of a sandbox id and resolves at delete time to whatever was pushed last — deleting it through a dead lifetime's row deletes the live one's checkpoint;
- a digest tag is content-addressed, so two lifetimes that checkpointed identical memory share it;
- the live lifetime's own retained history rows are its recovery points.
A dead lifetime's rows protect nothing: that is what lets two of them that share a manifest still be reclaimed.
rowIncarnation is the lifetime that recorded the row. A rolling pointer (<lifetime>-latest) is only ever written by its own lifetime, so it is in use exactly when that lifetime is the live one — and a dead lifetime's pointer is safe to delete however the live lifetime is doing, because nothing the live lifetime publishes can ever move it.
func (*Store) WasmDigestsInUse ¶ added in v0.5.3
func (s *Store) WasmDigestsInUse(ctx context.Context, digests []string) (map[string]struct{}, error)
WasmDigestsInUse returns the subset of digests that are still referenced by a live sandbox OR pinned by a catalogue row. The cache evictor calls this ONCE per sweep with every candidate digest instead of two probes per file, so a large cache no longer issues O(files) serialized queries against the single-writer DB (codex P1). Digests are chunked to stay under SQLite's bound parameter limit.
func (*Store) WriteIdentityKeys ¶ added in v0.6.12
func (s *Store) WriteIdentityKeys(ctx context.Context, expected int64, keys []cloudidentity.KeyRecord) (cloudidentity.KeySet, error)
WriteIdentityKeys replaces the key set if its generation is still expected, and returns the stored set (generation expected+1).
func (*Store) WriteNetworkPolicy ¶ added in v0.6.6
WriteNetworkPolicy stores a sandbox's policy, its profile references and its inline list in one transaction, so the effective list on the row and the references that explain it never disagree. A reference that stays keeps its applied generation.
func (*Store) WriteSecretAuditIndex ¶ added in v0.6.1
func (s *Store) WriteSecretAuditIndex(ctx context.Context, expect, meta SecretAuditIndexMeta, chunks []SecretAuditIndexChunk) error
WriteSecretAuditIndex replaces the given chunks (by primary key) and advances meta in one transaction. expect is the meta the chunks were computed against; if the stored meta has moved, nothing is written and ErrSecretAuditIndexStale is returned so the caller recomputes.
type WasmCheckpointPushRecord ¶ added in v0.5.3
type WasmCheckpointPushRecord struct {
ID int64
SandboxID string
// IncarnationID is the sandbox lifetime the push belonged to. Empty on
// cleanup-only rows a destroy recorded for refs it had no push row for.
IncarnationID string
RegistryRef string
Digest string
PushedAt time.Time
}
WasmCheckpointPushRecord is one AOCR push history row.
type WasmModuleRecord ¶ added in v0.5.3
type WasmModuleRecord struct {
ID string
ModuleRef string
Status string
ModulePath string
ModuleSizeBytes int64
Digest string
Entrypoint string
HasWarm bool
LastError string
// OwnerRef is the tenant that owns this catalogue row. "" means an
// operator-published module (readable by all tenants, writable only by the
// operator). See the wasm_modules.owner_ref column comment.
OwnerRef string
CreatedAt time.Time
UpdatedAt time.Time
ReadyAt *time.Time
}
WasmModuleRecord is one row in wasm_modules.