The control plane uses whichever mirror answers
mirror.peers names the mirrors kept in step with mirror.api. The mirror's management calls go to the first that can be reached, and each mirror is asked every fifteen seconds whether it answers: a shard is sent its model's and adapters' address on one that does while the mirror the catalog names is down. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5bc71b3d0a
commit
8a76a53afb
11 files changed
+276
-21
No files matched your search
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"runtime"
|
||||
"slices"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1"
|
||||
@@ -189,8 +191,31 @@ func AdoptedFromRegister(nodeID string, shards []*llmgwv1.RunningShard) []reconc
|
||||
}
|
||||
|
||||
// StartShardFromCommand converts a reconciler command into a wire message.
|
||||
// sourceRewrite is where a model is fetched while its mirror is down: set
|
||||
// when mirrors are kept in step, else nil and the catalog's address as it is.
|
||||
var sourceRewrite atomic.Pointer[func(string) string]
|
||||
|
||||
// SetSourceRewrite has every shard started from now on fetch its model, and
|
||||
// adapters, from the address f gives: one on a mirror that answers.
|
||||
func SetSourceRewrite(f func(string) string) { sourceRewrite.Store(&f) }
|
||||
|
||||
func rewriteSource(src string) string {
|
||||
if f := sourceRewrite.Load(); f != nil && src != "" {
|
||||
return (*f)(src)
|
||||
}
|
||||
return src
|
||||
}
|
||||
|
||||
func StartShardFromCommand(cmd reconciler.ShardCommand) *llmgwv1.StartShard {
|
||||
p := cmd.Spec.Profile
|
||||
p.ModelPath = rewriteSource(p.ModelPath)
|
||||
if len(p.Adapters) > 0 {
|
||||
ads := slices.Clone(p.Adapters)
|
||||
for i := range ads {
|
||||
ads[i].Path = rewriteSource(ads[i].Path)
|
||||
}
|
||||
p.Adapters = ads
|
||||
}
|
||||
return &llmgwv1.StartShard{
|
||||
ReplicaId: cmd.ReplicaID,
|
||||
ShardId: cmd.ShardID,
|
||||
|
||||
Reference in new issue
Block a user