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 InstalledEgress
- type NetworkPolicyWrite
- type NodeStorageRetirement
- type PendingEgressRuleClear
- type PendingImageGCEntry
- type ProfileRef
- type ReserveHostPortResult
- type SandboxEgressProfiles
- type SecretAuditIndexChunk
- type SecretAuditIndexKey
- type SecretAuditIndexMeta
- type SecretDeleteOutboxRecord
- type SecretLifecycleStats
- type SecretPutOutboxRecord
- type SnapshotPageQuery
- type SnapshotPageRow
- 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) 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) 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) 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) 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) Delete(ctx context.Context, id 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) 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, name string) error
- func (s *Store) DeleteSnapshotAlias(ctx context.Context, alias 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) DeleteVolumeIfUnattached(ctx context.Context, tenant, id, fallbackSource string) error
- func (s *Store) DeleteWasmCheckpointPush(ctx context.Context, id int64) error
- func (s *Store) DeleteWasmModule(ctx context.Context, 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) 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) 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) 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) 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) 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, name string) (*models.SandboxSnapshot, error)
- func (s *Store) GetSnapshotAlias(ctx context.Context, alias string) (*models.SnapshotAlias, error)
- func (s *Store) GetSnapshotByNames(ctx context.Context, names []string) (*models.SandboxSnapshot, error)
- func (s *Store) GetSnapshotsByImage(ctx context.Context, images []string) ([]*models.SandboxSnapshot, 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) GetWasmModule(ctx context.Context, 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) HasSandboxAuditACL(ctx context.Context, sandboxID, incarnationID string) (bool, 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) IsWasmModuleReferenced(ctx context.Context, 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) 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) 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) 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) 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) 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) ListSnapshotsPendingPush(ctx context.Context) ([]*models.SandboxSnapshot, 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) ListVolumes(ctx context.Context, tenant string) ([]models.Volume, 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) 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) 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) 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) PutVolumeAttachments(ctx context.Context, attachments []models.VolumeAttachment) error
- func (s *Store) PutWasmStateKV(ctx context.Context, sandboxID, key string, value []byte) 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) 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) RemoveCustomDomain(ctx context.Context, sandboxID, hostname string) 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) RetireClusterSecretGeneration(ctx context.Context, sandboxID, incarnationID string, generation int64) 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) 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) 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) SetSnapshotPushState(ctx context.Context, name, state, errMsg string) error
- func (s *Store) SetTemplatePushState(ctx context.Context, id, state, errMsg string) 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) 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) UpdateSandboxNetCounters(ctx context.Context, id string, deltaIn, deltaOut int64) 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) UpdateSnapshotImageDistribution(ctx context.Context, name, mode, registryRef, digest string) error
- func (s *Store) UpdateStatus(ctx context.Context, id string, status models.SandboxStatus, lastError string) error
- func (s *Store) UpdateTags(ctx context.Context, id string, tags map[string]string) error
- func (s *Store) UpdateTemplatePushDistribution(ctx context.Context, id, ref, digest 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) 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" )
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
SetTemplatePushState is a narrow single-column update used by the push reconciler. errMsg is overwritten unconditionally (including to empty on success transitions) so callers don't have to remember to clear it. Mirrors SetSnapshotPushState. 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.
Variables ¶
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 = errors.New("container netns pool: no free slot")
ErrNoFreeContainerNetnsSlot is returned when the netns pool is exhausted.
var ErrNoFreeFirecrackerTapSlot = errors.New("firecracker tap pool: no free slot")
ErrNoFreeFirecrackerTapSlot is returned by AllocateFirecrackerTapSlot when every slot is claimed. The Firecracker create path translates this into a 503-ish admission error upstream — operators see "pool exhausted" before the customer sees a confusing timeout.
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 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.
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
}
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 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 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 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 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 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 implementation is a two-step inside the SQLite single-writer window:
- SELECT a row WHERE sandbox_id IS NULL LIMIT 1.
- UPDATE that row SET sandbox_id = ?, allocated_at = ? WHERE tap_name = ? AND sandbox_id IS NULL.
The WHERE clause on UPDATE re-checks sandbox_id IS NULL so a race with a concurrent allocate of the same row updates RowsAffected=0 and we loop. SQLite's single-writer model makes this contest rare in practice but the code stays correct under any future change.
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 (the partial unique index makes a duplicate claim a hard error, but the pre-check yields a cleaner happy path). If no 'loaded' slot for templateID exists, returns ErrNoFreeFirecrackerVMMSlot — PR 4-B's caller falls back to cold spawn rather than failing the create.
The allocator shape is lifted from AllocateFirecrackerTapSlot: SELECT one free row, UPDATE WHERE row is still free. The UPDATE's WHERE re-checks status='loaded' AND sandbox_id IS NULL so a race against a concurrent allocator updates RowsAffected=0 and we loop. SQLite's single writer makes the contest rare, but the loop keeps correctness if the locking model ever changes.
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) 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) 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) 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) 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) 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) 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
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) 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) 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) DeleteWasmCheckpointPush ¶ added in v0.5.3
DeleteWasmCheckpointPush removes one push history row by id.
func (*Store) DeleteWasmModule ¶ added in v0.5.3
DeleteWasmModule removes a wasm_modules catalogue row.
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) 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) 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) 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) 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) 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, 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) 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) GetWasmModule ¶ added in v0.5.3
GetWasmModule returns one wasm_modules row by catalogue id.
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) 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) 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) 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) 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) 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) 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) 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) 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 module_ref values for ready catalogue rows.
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) 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) ListSnapshotsPendingPush ¶ added in v0.2.4
ListSnapshotsPendingPush returns snapshots the reconciler should retry — 'pending' is the brand-new state set by the snapshot-create path, 'error' is what a failed previous attempt left behind. 'pushing' is intentionally excluded so a row currently being processed by another reconciler tick (or a still-running goroutine kicked off by snapshot-create) is not re-claimed before its terminal state lands.
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. Mirrors ListSnapshotsPendingPush exactly.
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) 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) 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 newest-first.
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) 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) 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) 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) 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) PutWasmStateKV ¶ added in v0.5.3
PutWasmStateKV upserts one durable host-KV row (§4.6).
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) 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) 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) 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.
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) 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) 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) 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) 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) SetSnapshotPushState ¶ added in v0.2.4
SetSnapshotPushState is a narrow single-column update used by the push reconciler. errMsg is overwritten unconditionally (including to empty on success transitions) so callers don't have to remember to clear it.
func (*Store) SetTemplatePushState ¶ added in v0.4.1
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) 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) UpdateSandboxNetCounters ¶ added in v0.1.7
func (s *Store) UpdateSandboxNetCounters(ctx context.Context, id string, deltaIn, deltaOut int64) error
UpdateSandboxNetCounters bumps the cumulative ingress/egress counters by the given deltas. Both values are non-negative byte counts measured since the last sample. Concurrent calls are serialized by SQLite's single writer, and the UPDATE is atomic so a failed sample never partially applies. Returns ErrNotFound if the sandbox row was deleted between the poller's snapshot and this write — the netstats poller treats that as a cleanup signal and drops the in-memory baseline.
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) UpdateSnapshotImageDistribution ¶ added in v0.2.4
func (s *Store) UpdateSnapshotImageDistribution(ctx context.Context, name, mode, registryRef, digest string) error
UpdateSnapshotImageDistribution flips the distribution metadata on a snapshot row after a successful AOCR push — local_only → aocr. Called from the reconciler success path together with SetSnapshotPushState. VerifiedAt records when the push completed; cluster placement on other nodes uses this together with the new mode to decide the snapshot is fan-outable.
func (*Store) UpdateStatus ¶
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) UpdateTemplatePushDistribution ¶ added in v0.4.1
UpdateTemplatePushDistribution stamps the registry destination metadata after a successful AOCR push. ref is the canonical repo:tag the daemon pushed; digest is the manifest digest the registry surfaced via the push stream's `aux` payload (may be empty). Called from the reconciler success path together with SetTemplatePushState.
Written in one statement so a crash between the two fields cannot land a half-filled row — the consumer-side pull in PR 6-B.2 sees either both fields populated or both empty.
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.
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) 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
CreatedAt time.Time
UpdatedAt time.Time
ReadyAt *time.Time
}
WasmModuleRecord is one row in wasm_modules.