Bound pool declaration reads and document operator commands
This commit is contained in:
+15
@@ -16,6 +16,21 @@ service manager directly. Legacy Python-managed installations require an explici
|
||||
For source development, use `go run ./cmd/pipelines help`; start the native server
|
||||
separately. Set `PIPELINES_URL` or pass `--url` to select another server.
|
||||
|
||||
## Local resource pools
|
||||
|
||||
`pipelines resource-pool-inspect NAME --json` reads a declared pool's members,
|
||||
enabled/quarantined status and non-secret metadata. It does not report lease tokens.
|
||||
`pipelines resource-pool-configure pool.json --yes --json` replaces the full pool
|
||||
declaration; use `-` instead of a file to read stdin. Input is limited to 256 KiB.
|
||||
Without `--yes`, interactive confirmation is required. Both commands require the
|
||||
loopback operator transport; ordinary remote/stage clients are refused.
|
||||
|
||||
Declarations contain `name` and `members`, each with `member`, `enabled`, optional
|
||||
`quarantined` and bounded string `metadata`. Existing validation limits the member
|
||||
count to 32 and metadata to 16 fields per member. Configuration does not release
|
||||
active owners, discard waiters or prove a device is ready; inspect ownership and
|
||||
verify readiness before activating a target. Never put credentials in metadata.
|
||||
|
||||
## Dashboard and status
|
||||
|
||||
`pipelines --url ws://HOST:PORT/connect ping --json` returns `pong` with the
|
||||
|
||||
+14
-2
@@ -1002,13 +1002,25 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
}
|
||||
var data []byte
|
||||
if file == "-" {
|
||||
data, err = io.ReadAll(a.In)
|
||||
input := a.In
|
||||
if input == nil {
|
||||
input = os.Stdin
|
||||
}
|
||||
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
|
||||
} else {
|
||||
data, err = os.ReadFile(file)
|
||||
var input *os.File
|
||||
input, err = os.Open(file)
|
||||
if err == nil {
|
||||
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
|
||||
_ = input.Close()
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(data) > 256*1024 {
|
||||
return fmt.Errorf("resource pool input exceeds 262144 bytes")
|
||||
}
|
||||
var pool protocol.ResourcePool
|
||||
if err := json.Unmarshal(data, &pool); err != nil {
|
||||
return fmt.Errorf("invalid resource pool JSON: %w", err)
|
||||
|
||||
@@ -415,6 +415,22 @@ func TestResourcePoolOperatorCLIConfigureReadbackAndPreserveLease(t *testing.T)
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
for _, fromStdin := range []bool{false, true} {
|
||||
oversized := strings.Repeat(" ", 256*1024+1)
|
||||
path := filepath.Join(t.TempDir(), "oversized.json")
|
||||
if err := os.WriteFile(path, []byte(oversized), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fromStdin {
|
||||
path = "-"
|
||||
}
|
||||
bounded := cli.App{Out: &out, Err: &out, In: strings.NewReader(oversized)}
|
||||
err := bounded.Run(ctx, []string{"--url", endpoint, "resource-pool-configure", path, "--yes", "--json"})
|
||||
if err == nil || !strings.Contains(err.Error(), "exceeds 262144 bytes") {
|
||||
t.Fatalf("oversized pool input (stdin=%v): %v", fromStdin, err)
|
||||
}
|
||||
out.Reset()
|
||||
}
|
||||
app := cli.App{Out: &out, Err: &out, In: strings.NewReader("")}
|
||||
if err := app.Run(ctx, []string{"--url", "ws" + strings.TrimPrefix(srv.URL, "http"), "resource-pool-configure", declaration, "--yes", "--json"}); err != nil {
|
||||
t.Fatalf("configure CLI: %v\n%s", err, out.String())
|
||||
|
||||
Reference in New Issue
Block a user