A model can be stopped and kept, or removed with its files from the mirror and the nodes
CI / test (push) Successful in 10m37s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 20:45:48 +01:00
1 parent 5726ceb84e
commit 59187cdae5
19 files changed
+760 -14

No files matched your search

+35
View File
@@ -228,6 +228,8 @@ func (s *Service) Remove(ctx context.Context, name string) error {
func (s *Service) Scale(ctx context.Context, name string, sc catalog.Scaling, by string) (catalog.Model, error) {
final, err := s.update(ctx, name, by, "change its scaling", func(m *catalog.Model) error {
m.Scaling = sc
// A number set is what it runs now: a stopped model is started by it.
m.Stopped = nil
return nil
})
if err == nil {
@@ -237,6 +239,39 @@ func (s *Service) Scale(ctx context.Context, name string, sc catalog.Scaling, by
return final, err
}
// Stop takes a model out of service and keeps it: none of its replicas run,
// and what it was scaled to is kept for Start.
func (s *Service) Stop(ctx context.Context, name, by string) (catalog.Model, error) {
final, err := s.update(ctx, name, by, "stop it", func(m *catalog.Model) error {
if m.Stopped != nil {
return fmt.Errorf("model %q is already stopped; llmgw ctl model start %s runs it again", name, name)
}
was := m.Scaling
m.Stopped = &was
m.Scaling = catalog.Scaling{IdleTimeout: was.IdleTimeout}
return nil
})
if err == nil {
s.log.Info("model stopped", "model", name, "by", by)
}
return final, err
}
// Start runs a stopped model again, scaled as it was when it was stopped.
func (s *Service) Start(ctx context.Context, name, by string) (catalog.Model, error) {
final, err := s.update(ctx, name, by, "start it", func(m *catalog.Model) error {
if m.Stopped == nil {
return fmt.Errorf("model %q is not stopped; llmgw ctl scale changes how many replicas it runs", name)
}
m.Scaling, m.Stopped = *m.Stopped, nil
return nil
})
if err == nil {
s.log.Info("model started", "model", name, "min", final.Scaling.Min, "max", final.Scaling.Max, "by", by)
}
return final, err
}
// Resources sets what a model's profile reserves of a node: host memory, and
// the CPU cores a replica without a GPU computes on. An empty profile name
// sets every profile.