Documentation
¶
Index ¶
- Constants
- Variables
- func IdentityKey(registryID int, registryType, repo, revision string, files []string) string
- func RefuseLocalKnowledgeApply() error
- type Manager
- func (m *Manager) ActivePullNames() []string
- func (m *Manager) ApplyControllerKnowledge(ctx context.Context, items []*models.ControllerKnowledge) error
- func (m *Manager) ApplyManifest(doc *models.LocalKnowledgeManifest) (*models.LocalKnowledge, error)
- func (m *Manager) Ensure(needed int64) error
- func (m *Manager) GetPull(operationID string) (*PullOperation, bool)
- func (m *Manager) LoadDesired() ([]*models.LocalKnowledge, []*models.ControllerKnowledge, 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) SaveControllerKnowledge(items []*models.ControllerKnowledge) 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.LocalKnowledge) (*models.LocalKnowledge, error)
- type PruneReport
- type PullOperation
- type Puller
Constants ¶
const ( // MaxConcurrentPulls is the global cap on in-flight Knowledge downloads. // This pool is independent of Model pulls. MaxConcurrentPulls = 2 // DefaultPullTimeout is the default deadline for one Knowledge pull. DefaultPullTimeout = 6 * time.Hour OpStatusRunning = "running" OpStatusSucceeded = "succeeded" OpStatusFailed = "failed" )
const (
PruneModeDangling = "dangling"
)
Variables ¶
var ErrLocalKnowledgeDisabled = errors.New("local knowledge is disabled while watchdog is enabled")
ErrLocalKnowledgeDisabled is returned when local Knowledge 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 RefuseLocalKnowledgeApply ¶
func RefuseLocalKnowledgeApply() error
RefuseLocalKnowledgeApply returns ErrLocalKnowledgeDisabled when watchdog is on.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager reconciles local Knowledge desired state and orchestrates artifact pulls.
func New ¶
New constructs a Manager that reads desired Knowledge from db and writes under knowledgeRoot.
func (*Manager) ActivePullNames ¶
ActivePullNames returns Knowledge names that currently have an in-flight pull.
func (*Manager) ApplyControllerKnowledge ¶
func (m *Manager) ApplyControllerKnowledge(ctx context.Context, items []*models.ControllerKnowledge) error
ApplyControllerKnowledge replaces the fleet-desired Knowledge snapshot and upserts each row as a managed local Knowledge. A managed Knowledge occupies that on-disk name.
func (*Manager) ApplyManifest ¶
func (m *Manager) ApplyManifest(doc *models.LocalKnowledgeManifest) (*models.LocalKnowledge, error)
ApplyManifest upserts a validated Knowledge 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.LocalKnowledge, []*models.ControllerKnowledge, error)
LoadDesired returns local Knowledge rows plus any persisted controller Knowledge rows.
func (*Manager) Prune ¶
func (m *Manager) Prune(mode string) (*PruneReport, error)
Prune removes unused Knowledge artifacts. The only supported mode is dangling.
func (*Manager) PruneDangling ¶
func (m *Manager) PruneDangling() (*PruneReport, error)
PruneDangling removes unused local Knowledge rows and trees that are not in the keep set, then drops unreferenced blobs in knowledge/oci-store/.
func (*Manager) Reconcile ¶
Reconcile compares desired local Knowledge to on-disk state and starts pulls when needed.
func (*Manager) Remove ¶
Remove deletes one deployed Knowledge, its on-disk tree, and unused shared blobs.
func (*Manager) SaveControllerKnowledge ¶
func (m *Manager) SaveControllerKnowledge(items []*models.ControllerKnowledge) error
SaveControllerKnowledge persists fleet-desired Knowledge 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.
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 Knowledge 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.LocalKnowledge) (*models.LocalKnowledge, error)
UpsertDesired inserts or updates a local Knowledge 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 Knowledge 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.
func (PullOperation) Snapshot ¶
func (op PullOperation) Snapshot() map[string]any
Snapshot returns a JSON-ready view of the operation.