Fixes from review: setup's memory check, MCP secrets, VS Code, bandwidth
CI / test (push) Successful in 9m47s
CI / test (push) Successful in 9m47s
- server init run again on a machine already set up is not refused its memory (the docs fix a certificate with --host so), and judges count only when one will be installed (judgeComes: not without a mirror, nor from a bundle without it). - A server's sealed secrets that it no longer reads are removed when it is put or deleted; replacing a credential replaces every header it was sent, rather than adding one beside the old. - llmgw.gatewayUrl is a machine setting and restricted in untrusted workspaces: a cloned repository's settings cannot send a sign-in to another gateway. - The bandwidth buffer is at least eight times the CPU's last cache and at most a quarter of free memory, else nothing is measured until there is room; a registration carries the figure measured so far. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54c6b66cb9
commit
b986ea180d
12 files changed
+197
-20
No files matched your search
@@ -365,12 +365,7 @@ func (in *serverInit) run(ctx context.Context) error {
|
||||
// judgeWanted is whether this install fetches the judge model, and so
|
||||
// whether the baseline policy asks it.
|
||||
func (in *serverInit) judgeWanted() bool {
|
||||
if in.noGuardModel || (in.noMirror && in.mirrorURL == "") || in.unitPath == "" {
|
||||
return false
|
||||
}
|
||||
// Offline, only a judge the bundle carries: a policy asking a judge
|
||||
// that never comes refuses every request.
|
||||
if in.bundle != "" && !in.bundleCarries(guardModelName) {
|
||||
if !in.judgeComes() || in.unitPath == "" {
|
||||
return false
|
||||
}
|
||||
_, err := exec.LookPath("systemctl")
|
||||
@@ -1000,3 +995,13 @@ func virtualInterface(name string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// judgeComes is whether this setup has a judge to install: one not left
|
||||
// out, a mirror to fetch it from, and, offline, a bundle that carries it —
|
||||
// a policy asking a judge that never comes refuses every request.
|
||||
func (in *serverInit) judgeComes() bool {
|
||||
if in.noGuardModel || (in.noMirror && in.mirrorURL == "") {
|
||||
return false
|
||||
}
|
||||
return in.bundle == "" || in.bundleCarries(guardModelName)
|
||||
}
|
||||
@@ -176,7 +176,9 @@ func (in *serverInit) servingMemoryMB(judgesElsewhere bool) (mb int, what string
|
||||
gb += in.starterModelSpec().minMemoryGB()
|
||||
parts = append(parts, "the starter model")
|
||||
}
|
||||
if !in.noGuardModel && !judgesElsewhere {
|
||||
// Only judges that will be installed: none without a mirror to fetch
|
||||
// them from, or from a bundle that does not carry one.
|
||||
if !judgesElsewhere && in.judgeComes() {
|
||||
n := in.judgeFor().Replicas
|
||||
gb += n * judgeMemoryGB
|
||||
parts = append(parts, fmt.Sprintf("%d judges", n))
|
||||
@@ -193,6 +195,11 @@ func (in *serverInit) checkMemory() error {
|
||||
if in.unitPath == "" {
|
||||
return nil // a development run, served by nothing
|
||||
}
|
||||
// Run again on a machine already set up — to change --host, say, as
|
||||
// the docs advise — it installs no models it does not already serve.
|
||||
if _, err := os.Stat(in.configPath()); err == nil {
|
||||
return nil
|
||||
}
|
||||
meminfo, err := os.ReadFile("/proc/meminfo")
|
||||
if err != nil {
|
||||
return nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/preflight"
|
||||
@@ -24,4 +25,22 @@ func TestTheMemoryAMachineNeedsCountsWhatItServes(t *testing.T) {
|
||||
if mb, _ := (&serverInit{noModel: true, noGuardModel: true}).servingMemoryMB(false); mb != 0 {
|
||||
t.Errorf("nothing served: %d", mb)
|
||||
}
|
||||
// Without a mirror no judge is fetched, so none is counted.
|
||||
if mb, what := (&serverInit{noMirror: true}).servingMemoryMB(false); mb != 0 {
|
||||
t.Errorf("no mirror, nothing to fetch: %d %q", mb, what)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupRunAgainOnAMachineAlreadySetUpIsNotRefusedItsMemory(t *testing.T) {
|
||||
// The docs fix a certificate with server init --host on a machine set up
|
||||
// before the check: it installs nothing it does not already serve.
|
||||
dir := t.TempDir()
|
||||
cfg := dir + "/server.yaml"
|
||||
if err := os.WriteFile(cfg, []byte("listen: :8080\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
in := &serverInit{unitPath: dir + "/llmgw-server.service", etcDir: dir}
|
||||
if err := in.checkMemory(); err != nil {
|
||||
t.Errorf("refused: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -386,7 +386,7 @@ func (m *consoleModel) mcpCredentialForm(s adminapi.MCPServerView) {
|
||||
return nil, err
|
||||
}
|
||||
return m.call("Credential of "+s.Name, http.MethodPut, mcpPath(s.Name),
|
||||
adminapi.MCPServerRequest{URL: s.URL, Secrets: secrets}, nil), nil
|
||||
adminapi.MCPServerRequest{URL: s.URL, Secrets: secrets, HeaderRefs: map[string]string{}}, nil), nil
|
||||
}})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user