The judge init installs is no longer replaced by the leader's own
CI / test (push) Successful in 5m27s
CI / test (push) Successful in 5m27s
Found on a fresh HA install with a judge machine: the leader saw the policy's judge missing while init was still fetching it, served one itself, and its entry replaced init's, so a second judge ran off the judge machine. The keeper now waits ten minutes after it starts, and a serve job it starts gives way to a model added meanwhile (AddNew). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
34764f5ef0
commit
314cc5e6a3
9 files changed
+131
-2
No files matched your search
@@ -106,6 +106,17 @@ func (s *Service) Sources(ctx context.Context) (map[string][]catalog.Model, erro
|
||||
// than persisted and then skipped on every future start — which would be a
|
||||
// model that looks added and never appears.
|
||||
func (s *Service) Add(ctx context.Context, m catalog.Model, by string) error {
|
||||
return s.add(ctx, m, by, false)
|
||||
}
|
||||
|
||||
// AddNew is Add for a model nobody has added meanwhile: one that is in the
|
||||
// catalog by now is left as it is, and catalog.ErrExists said. The leader serving a
|
||||
// judge a policy names gives way so to the judge init added while it fetched.
|
||||
func (s *Service) AddNew(ctx context.Context, m catalog.Model, by string) error {
|
||||
return s.add(ctx, m, by, true)
|
||||
}
|
||||
|
||||
func (s *Service) add(ctx context.Context, m catalog.Model, by string, onlyNew bool) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
@@ -135,6 +146,9 @@ func (s *Service) Add(ctx context.Context, m catalog.Model, by string) error {
|
||||
next := s.base(stored)
|
||||
for _, e := range stored {
|
||||
if e.Name == m.Name {
|
||||
if onlyNew {
|
||||
return fmt.Errorf("model %q: %w", m.Name, catalog.ErrExists)
|
||||
}
|
||||
continue // this call replaces it
|
||||
}
|
||||
next = append(next, e)
|
||||
|
||||
@@ -3,6 +3,7 @@ package modelsvc
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -377,3 +378,25 @@ func TestResourcesAreSetOnAStoredModelAndSurviveARestart(t *testing.T) {
|
||||
t.Error("the cores were lost on reload")
|
||||
}
|
||||
}
|
||||
|
||||
// The leader serving a judge gives way to the one init added while it
|
||||
// fetched: AddNew leaves a model already there as it is.
|
||||
func TestAddNewLeavesAModelAddedMeanwhile(t *testing.T) {
|
||||
s, _, rec := newService(t)
|
||||
first := model("judge")
|
||||
first.Description = "init's"
|
||||
if err := s.Add(t.Context(), first, "init"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
second := model("judge")
|
||||
second.Description = "the leader's"
|
||||
if err := s.AddNew(t.Context(), second, "llmgw"); !errors.Is(err, catalog.ErrExists) {
|
||||
t.Fatalf("err %v", err)
|
||||
}
|
||||
if m, _ := rec.last.Resolve("judge"); m.Description != "init's" {
|
||||
t.Errorf("replaced: %q", m.Description)
|
||||
}
|
||||
if err := s.AddNew(t.Context(), model("fresh"), "llmgw"); err != nil {
|
||||
t.Errorf("a new model: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user