mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-12 22:33:54 -04:00
Node placement and replica rules could only name a model, so an operator who pinned "llama3" to the GPU tier had to rewrite the rule whenever a different model took over that job. An alias already gives a stable name for whichever model serves it, and a rule on that name makes it a deployment slot: repoint the alias and the placement follows. A rule keeps the name the operator chose. Reads resolve that name through the config loader to the model the rule governs, so the reconciler counts, schedules and trims replicas of the target, and the router finds an alias-keyed rule from the target it is already routing. An alias that resolves to nothing governs nothing loadable, so the reconciler skips it and the write paths refuse it. A replica is shared by every name that resolves to it, so only one rule can decide where it runs. The REST and MCP write paths reject a rule whose target another rule already governs. A pair that arrives some other way, such as a seed file or an alias repointed onto a model that already has a rule, resolves in favour of the rule named after the model itself and then the oldest, and the rest are listed as shadowed. The eviction guard is the exception: it matches rules to replicas in raw SQL inside a locking transaction and cannot resolve an alias. It reads a stored target that the reconciler refreshes each tick, and falls back to the rule's own name when that target is empty. Assisted-by: Claude:claude-opus-5 golangci-lint eslint Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
28 lines
945 B
Go
28 lines
945 B
Go
package localaitools
|
|
|
|
import "github.com/mudler/LocalAI/core/services/nodes"
|
|
|
|
func SchedulingConfigFromNode(config nodes.ModelSchedulingConfig) ModelSchedulingConfig {
|
|
return ModelSchedulingConfig{
|
|
ModelName: config.ModelName,
|
|
NodeSelector: config.NodeSelector,
|
|
MinReplicas: config.MinReplicas,
|
|
MaxReplicas: config.MaxReplicas,
|
|
SpreadAll: config.SpreadAll,
|
|
RoutePolicy: config.RoutePolicy,
|
|
BalanceAbsThreshold: config.BalanceAbsThreshold,
|
|
BalanceRelThreshold: config.BalanceRelThreshold,
|
|
MinPrefixMatch: config.MinPrefixMatch,
|
|
TargetModel: config.Target(),
|
|
Shadowed: config.Shadowed,
|
|
}
|
|
}
|
|
|
|
func SchedulingConfigsFromNodes(configs []nodes.ModelSchedulingConfig) []ModelSchedulingConfig {
|
|
out := make([]ModelSchedulingConfig, 0, len(configs))
|
|
for _, config := range configs {
|
|
out = append(out, SchedulingConfigFromNode(config))
|
|
}
|
|
return out
|
|
}
|