Documentation
¶
Index ¶
- Constants
- Variables
- func IdentityKey(registryID int, registryType, repo, revision string, files []string) string
- func RefuseLocalModelApply() error
- type Manager
- func (m *Manager) ApplyControllerModels(ctx context.Context, items []*models.ControllerModel) error
- func (m *Manager) ApplyManifest(doc *models.LocalModelManifest) (*models.LocalModel, error)
- func (m *Manager) Ensure(needed int64) error
- func (m *Manager) GetPull(operationID string) (*PullOperation, bool)
- func (m *Manager) LoadDesired() ([]*models.LocalModel, []*models.ControllerModel, error)
- func (m *Manager) Prune(mode string) (*PruneReport, error)
- func (m *Manager) PruneDangling() (*PruneReport, error)
- func (m *Manager) Reconcile(ctx context.Context) error
- func (m *Manager) Remove(name string) error
- func (m *Manager) SaveControllerModels(items []*models.ControllerModel) error
- func (m *Manager) SetDiskPolicy(directory string, thresholdPercent int64, ...)
- func (m *Manager) SetLiveConfig(cfg *config.Config)
- func (m *Manager) SetPullers(ociPuller, hfPuller Puller)
- func (m *Manager) SetTimeout(d time.Duration)
- func (m *Manager) StartPull(name string) (*PullOperation, error)
- func (m *Manager) UpsertDesired(incoming *models.LocalModel) (*models.LocalModel, error)
- type PruneReport
- type PullOperation
- type Puller
Constants ¶
const ( // MaxConcurrentPulls is the global cap on in-flight model downloads. MaxConcurrentPulls = 2 // DefaultPullTimeout is the default deadline for one model pull. DefaultPullTimeout = 6 * time.Hour OpStatusRunning = "running" OpStatusSucceeded = "succeeded" OpStatusFailed = "failed" )
const (
PruneModeDangling = "dangling"
)
Variables ¶
var ErrLocalModelsDisabled = errors.New("local models are disabled while watchdog is enabled")
ErrLocalModelsDisabled is returned when local Model apply or pull is refused because watchdog is enabled.
Functions ¶
func IdentityKey ¶
IdentityKey is the pull identity: registry id + type + repo + revision + hash(files).
func RefuseLocalModelApply ¶
func RefuseLocalModelApply() error
RefuseLocalModelApply returns ErrLocalModelsDisabled when watchdog is on.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager reconciles local Model desired state and orchestrates artifact pulls.
func (*Manager) ApplyControllerModels ¶
ApplyControllerModels replaces the fleet-desired Model snapshot and upserts each row as a managed local Model. A managed Model occupies that on-disk name.
func (*Manager) ApplyManifest ¶
func (m *Manager) ApplyManifest(doc *models.LocalModelManifest) (*models.LocalModel, error)
ApplyManifest upserts a validated Model document by metadata.name.
func (*Manager) GetPull ¶
func (m *Manager) GetPull(operationID string) (*PullOperation, bool)
GetPull returns a copy of one async pull operation.
func (*Manager) LoadDesired ¶
func (m *Manager) LoadDesired() ([]*models.LocalModel, []*models.ControllerModel, error)
LoadDesired returns local Model rows plus any persisted controller Model rows.
func (*Manager) Prune ¶
func (m *Manager) Prune(mode string) (*PruneReport, error)
Prune removes unused model artifacts. The only supported mode is dangling.
func (*Manager) PruneDangling ¶
func (m *Manager) PruneDangling() (*PruneReport, error)
PruneDangling removes unused local models (rows and on-disk trees) that are not in the keep set, then drops unreferenced blobs.
func (*Manager) Reconcile ¶
Reconcile compares desired local Models to on-disk state and starts pulls when needed.
func (*Manager) Remove ¶
Remove deletes one deployed model, its on-disk tree, and unused shared blobs.
func (*Manager) SaveControllerModels ¶
func (m *Manager) SaveControllerModels(items []*models.ControllerModel) error
SaveControllerModels persists fleet-desired Model rows without starting a sync worker.
func (*Manager) SetDiskPolicy ¶
func (m *Manager) SetDiskPolicy(directory string, thresholdPercent int64, stats func(path string) (free, total int64, err error))
SetDiskPolicy configures the free-space check used before a payload download.
func (*Manager) SetLiveConfig ¶
SetLiveConfig makes free-space checks read diskDirectory and availableDiskThreshold from the live Config singleton so CLI PATCH and controller config pushes apply without restarting the daemon.
func (*Manager) SetPullers ¶
SetPullers replaces the OCI and Hugging Face adapters (tests).
func (*Manager) SetTimeout ¶
SetTimeout overrides the default pull deadline.
func (*Manager) StartPull ¶
func (m *Manager) StartPull(name string) (*PullOperation, error)
StartPull begins an async pull for one model name. One in-flight pull per name; a second request returns the existing operation.
The caller context is not used after accept. Download runs on a detached background context so HTTP handlers can return 202 without canceling work.
func (*Manager) UpsertDesired ¶
func (m *Manager) UpsertDesired(incoming *models.LocalModel) (*models.LocalModel, error)
UpsertDesired inserts or updates a local Model row, bumping generation on spec drift.
type PruneReport ¶
type PruneReport struct {
Mode string `json:"mode"`
Removed []string `json:"removed"`
BlobsRemoved int `json:"blobsRemoved"`
StaleCleaned int `json:"staleCleaned"`
}
PruneReport is the outcome of a model prune.
type PullOperation ¶
type PullOperation struct {
OperationID string
Status string
Progress int
BytesDownloaded int64
BytesTotal int64
Name string
RegistryID int
Error string
StartedAt time.Time
EndedAt *time.Time
}
PullOperation is the async pull status record (mirrors images:pull where sensible).
func (PullOperation) Snapshot ¶
func (op PullOperation) Snapshot() map[string]any
Snapshot returns a JSON-ready view of the operation.