Every check the mesh had was right about the world it was given and none was given the mesh's: a real machine's name made an identity too long (263), the node-engine refused what the catalogue check passed (236). The controller now composes what a check needs - every machine under a pseudonym of its name's length, its roles, system, builds, capabilities, assignments, pins, settings and how its declaration composes; every seat, module and source; the bus, store and node-engine versions it runs - with no secret, no address and no name, and keeps it in the artifact store as facts:latest when it moved, or daily. The replaced snapshot's manifest is let go of, so the nightly collector takes it. S14 raises facts-stale past two days.
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package inventory
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
// Described is what a machine said about itself beyond its capabilities: the architecture and kernel
|
|
// its node-engine runs on (novox/hq to-be 45 §9, the facts snapshot).
|
|
type Described struct {
|
|
Architecture string `json:"architecture"`
|
|
Kernel string `json:"kernel"`
|
|
}
|
|
|
|
// DescribedOf is the architecture and kernel a machine last reported; empty for one that never has.
|
|
func (i *Inventory) DescribedOf(ctx context.Context, nodeName string) (Described, error) {
|
|
var raw []byte
|
|
err := i.store.Pool().QueryRow(ctx, `select profile from node where name = $1`, nodeName).Scan(&raw)
|
|
if errors.Is(err, pgx.ErrNoRows) {
|
|
return Described{}, fmt.Errorf("%w: %s", ErrNoSuchNode, nodeName)
|
|
}
|
|
if err != nil || len(raw) == 0 {
|
|
return Described{}, err
|
|
}
|
|
var r Described
|
|
if err := json.Unmarshal(raw, &r); err != nil {
|
|
return Described{}, err
|
|
}
|
|
return r, nil
|
|
}
|
|
|
|
// ServerVersion is the store's own word for the release it runs — the version a test suite standing in
|
|
// for it must run (novox/hq ADR 0227 rule 9).
|
|
func (i *Inventory) ServerVersion(ctx context.Context) (string, error) {
|
|
var v string
|
|
err := i.store.Pool().QueryRow(ctx, `show server_version`).Scan(&v)
|
|
return v, err
|
|
}
|