H2 composition-diff: the node-engine seat's read verb composition-diff
The node-engine serves seat verbs and has no tools bundle, so the composed values read by resource are a read verb beside composition: given a module and a revision or digest, the entries that differ between the running composition and the other, per resource, environment entries by name, a secret masked. Packages generated again by seatgen (seatgen -check clean). Builds: design 47 H2 §813 (3); H-A-349 DQ-12b
This commit is contained in:
@@ -23,6 +23,7 @@ const (
|
|||||||
VerbActs = "acts"
|
VerbActs = "acts"
|
||||||
VerbPackages = "packages"
|
VerbPackages = "packages"
|
||||||
VerbComposition = "composition"
|
VerbComposition = "composition"
|
||||||
|
VerbCompositionDiff = "composition-diff"
|
||||||
VerbCompose = "compose"
|
VerbCompose = "compose"
|
||||||
VerbComposeCandidate = "compose-candidate"
|
VerbComposeCandidate = "compose-candidate"
|
||||||
VerbManifestReads = "manifest-reads"
|
VerbManifestReads = "manifest-reads"
|
||||||
@@ -49,7 +50,7 @@ const (
|
|||||||
|
|
||||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||||
func Verbs() []string {
|
func Verbs() []string {
|
||||||
return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbApplyOrder, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds, VerbConverged}
|
return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompositionDiff, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbApplyOrder, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds, VerbConverged}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Events is every event published on the seat's subject: a new copy each call.
|
// Events is every event published on the seat's subject: a new copy each call.
|
||||||
@@ -625,6 +626,26 @@ type Composed struct {
|
|||||||
V int64 `json:"v"`
|
V int64 `json:"v"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CompositionDiffEntry is one entry that differs between the running composition and the other.
|
||||||
|
type CompositionDiffEntry struct {
|
||||||
|
// the value is a secret, so neither value is given
|
||||||
|
Masked bool `json:"masked,omitempty"`
|
||||||
|
// the entry: an environment entry by its name, else the part of the resource that differs
|
||||||
|
Name string `json:"name"`
|
||||||
|
// its value in the other composition; absent where the other lacks it or the value is a secret
|
||||||
|
Other string `json:"other,omitempty"`
|
||||||
|
// its value in the running composition; absent where the running one lacks it or the value is a secret
|
||||||
|
Running string `json:"running,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompositionDiffResource is one resource with the entries of it that differ.
|
||||||
|
type CompositionDiffResource struct {
|
||||||
|
// the entries of the resource that differ
|
||||||
|
Entries []CompositionDiffEntry `json:"entries"`
|
||||||
|
// the resource, as the composition names it
|
||||||
|
Resource string `json:"resource"`
|
||||||
|
}
|
||||||
|
|
||||||
// DeclaredGroup is a group.
|
// DeclaredGroup is a group.
|
||||||
type DeclaredGroup struct {
|
type DeclaredGroup struct {
|
||||||
Gid int64 `json:"gid"`
|
Gid int64 `json:"gid"`
|
||||||
@@ -1338,6 +1359,29 @@ type CompositionAnswer struct {
|
|||||||
WithheldUnknown string `json:"withheld-unknown,omitempty"`
|
WithheldUnknown string `json:"withheld-unknown,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CompositionDiffInput is what composition-diff takes.
|
||||||
|
type CompositionDiffInput struct {
|
||||||
|
// the digest (sha256:…) of the composition to compare with; give it or revision
|
||||||
|
Digest string `json:"digest,omitempty"`
|
||||||
|
// the module, as placed on this machine; node for the node's own
|
||||||
|
Module string `json:"module"`
|
||||||
|
// the revision of the module's composition key to compare with, from the revisions the bucket keeps; give it or digest
|
||||||
|
Revision int64 `json:"revision,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompositionDiffAnswer is what composition-diff answers.
|
||||||
|
type CompositionDiffAnswer struct {
|
||||||
|
// the module
|
||||||
|
Module string `json:"module"`
|
||||||
|
// the node
|
||||||
|
Node string `json:"node"`
|
||||||
|
Other *Revision `json:"other,omitempty"`
|
||||||
|
// each resource with an entry that differs; empty when none differs
|
||||||
|
Resources []CompositionDiffResource `json:"resources"`
|
||||||
|
// the digest of the composition that runs; absent when nothing runs
|
||||||
|
Running string `json:"running,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ComposeInput is what compose takes.
|
// ComposeInput is what compose takes.
|
||||||
type ComposeInput struct {
|
type ComposeInput struct {
|
||||||
// a module placed on this machine whose apply is also tried again (optional)
|
// a module placed on this machine whose apply is also tried again (optional)
|
||||||
|
|||||||
@@ -135,6 +135,12 @@ func TestFixtures(t *testing.T) {
|
|||||||
decode: func(b []byte) (any, error) { var v ConvergedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
decode: func(b []byte) (any, error) { var v ConvergedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
{name: "composition names the filter part kept because allowed did not answer", subject: "", given: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}", wire: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}",
|
{name: "composition names the filter part kept because allowed did not answer", subject: "", given: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}", wire: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}",
|
||||||
decode: func(b []byte) (any, error) { var v CompositionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
decode: func(b []byte) (any, error) { var v CompositionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
|
{name: "composition-diff asks a module against a digest", subject: "", given: "{\"digest\":\"sha256:aa\",\"module\":\"plex\"}", wire: "{\"digest\":\"sha256:aa\",\"module\":\"plex\"}",
|
||||||
|
decode: func(b []byte) (any, error) { var v CompositionDiffInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
|
{name: "composition-diff answers the entries that differ per resource, a secret masked", subject: "", given: "{\"module\":\"plex\",\"node\":\"ace\",\"other\":{\"digest\":\"sha256:aa\",\"key\":\"plex\",\"revision\":12},\"resources\":[{\"entries\":[{\"name\":\"PLEX_LOG_LEVEL\",\"other\":\"debug\",\"running\":\"info\"},{\"masked\":true,\"name\":\"PLEX_TOKEN\"}],\"resource\":\"service:plex\"}],\"running\":\"sha256:bb\"}", wire: "{\"module\":\"plex\",\"node\":\"ace\",\"other\":{\"digest\":\"sha256:aa\",\"key\":\"plex\",\"revision\":12},\"resources\":[{\"entries\":[{\"name\":\"PLEX_LOG_LEVEL\",\"other\":\"debug\",\"running\":\"info\"},{\"masked\":true,\"name\":\"PLEX_TOKEN\"}],\"resource\":\"service:plex\"}],\"running\":\"sha256:bb\"}",
|
||||||
|
decode: func(b []byte) (any, error) { var v CompositionDiffAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
|
{name: "composition-diff answers no resource when none differs", subject: "", given: "{\"module\":\"plex\",\"node\":\"ace\",\"resources\":[],\"running\":\"sha256:aa\"}", wire: "{\"module\":\"plex\",\"node\":\"ace\",\"resources\":[],\"running\":\"sha256:aa\"}",
|
||||||
|
decode: func(b []byte) (any, error) { var v CompositionDiffAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
v, err := c.decode([]byte(c.given))
|
v, err := c.decode([]byte(c.given))
|
||||||
|
|||||||
@@ -332,5 +332,53 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "composition-diff asks a module against a digest",
|
||||||
|
"of": "verb:composition-diff.input",
|
||||||
|
"given": {
|
||||||
|
"module": "plex",
|
||||||
|
"digest": "sha256:aa"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "composition-diff answers the entries that differ per resource, a secret masked",
|
||||||
|
"of": "verb:composition-diff.answer",
|
||||||
|
"given": {
|
||||||
|
"node": "ace",
|
||||||
|
"module": "plex",
|
||||||
|
"running": "sha256:bb",
|
||||||
|
"other": {
|
||||||
|
"key": "plex",
|
||||||
|
"revision": 12,
|
||||||
|
"digest": "sha256:aa"
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"resource": "service:plex",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"name": "PLEX_LOG_LEVEL",
|
||||||
|
"running": "info",
|
||||||
|
"other": "debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PLEX_TOKEN",
|
||||||
|
"masked": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "composition-diff answers no resource when none differs",
|
||||||
|
"of": "verb:composition-diff.answer",
|
||||||
|
"given": {
|
||||||
|
"node": "ace",
|
||||||
|
"module": "plex",
|
||||||
|
"running": "sha256:aa",
|
||||||
|
"resources": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -550,6 +550,63 @@
|
|||||||
},
|
},
|
||||||
"class": "read"
|
"class": "read"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "composition-diff",
|
||||||
|
"description": "One module's composed values read by resource (design 47 H2 \u00a7813 (3), H-A-349 DQ-12b): given a module and a revision or a digest of its composition, the entries that differ between the composition that runs and that one, per resource, environment entries by name, a secret's value masked. Read-only. Answered by this machine's engine alone.",
|
||||||
|
"class": "read",
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"module"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"module": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the module, as placed on this machine; node for the node's own"
|
||||||
|
},
|
||||||
|
"revision": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "the revision of the module's composition key to compare with, from the revisions the bucket keeps; give it or digest"
|
||||||
|
},
|
||||||
|
"digest": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the digest (sha256:\u2026) of the composition to compare with; give it or revision"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"node",
|
||||||
|
"module",
|
||||||
|
"resources"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"node": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the node"
|
||||||
|
},
|
||||||
|
"module": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the module"
|
||||||
|
},
|
||||||
|
"running": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the digest of the composition that runs; absent when nothing runs"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"$ref": "#/defs/Revision"
|
||||||
|
},
|
||||||
|
"resources": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "each resource with an entry that differs; empty when none differs",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/defs/CompositionDiffResource"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "compose",
|
"name": "compose",
|
||||||
"description": "Compose this machine's modules now and say how it went, so a composition that failed, or a module held, recovers without a restart: what the pass refused or held, each with why, and when the engine composes again on its own after a seat that did not answer (a deadline, no responders: retried with a growing wait; a refusal never). With module, that module's apply is also tried again. Changes only what a pass the engine makes on its own would change.",
|
"description": "Compose this machine's modules now and say how it went, so a composition that failed, or a module held, recovers without a restart: what the pass refused or held, each with why, and when the engine composes again on its own after a seat that did not answer (a deadline, no responders: retried with a growing wait; a refusal never). With module, that module's apply is also tried again. Changes only what a pass the engine makes on its own would change.",
|
||||||
@@ -3398,6 +3455,52 @@
|
|||||||
"step",
|
"step",
|
||||||
"since"
|
"since"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"CompositionDiffEntry": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the entry: an environment entry by its name, else the part of the resource that differs"
|
||||||
|
},
|
||||||
|
"running": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "its value in the running composition; absent where the running one lacks it or the value is a secret"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "its value in the other composition; absent where the other lacks it or the value is a secret"
|
||||||
|
},
|
||||||
|
"masked": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "the value is a secret, so neither value is given"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "one entry that differs between the running composition and the other"
|
||||||
|
},
|
||||||
|
"CompositionDiffResource": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"resource",
|
||||||
|
"entries"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"resource": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the resource, as the composition names it"
|
||||||
|
},
|
||||||
|
"entries": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/defs/CompositionDiffEntry"
|
||||||
|
},
|
||||||
|
"description": "the entries of the resource that differ"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "one resource with the entries of it that differ"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+44
@@ -13,6 +13,7 @@ export declare const verbs: {
|
|||||||
readonly acts: "acts";
|
readonly acts: "acts";
|
||||||
readonly packages: "packages";
|
readonly packages: "packages";
|
||||||
readonly composition: "composition";
|
readonly composition: "composition";
|
||||||
|
readonly compositionDiff: "composition-diff";
|
||||||
readonly compose: "compose";
|
readonly compose: "compose";
|
||||||
readonly composeCandidate: "compose-candidate";
|
readonly composeCandidate: "compose-candidate";
|
||||||
readonly manifestReads: "manifest-reads";
|
readonly manifestReads: "manifest-reads";
|
||||||
@@ -304,6 +305,26 @@ export interface Composed {
|
|||||||
"v": number;
|
"v": number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** one entry that differs between the running composition and the other */
|
||||||
|
export interface CompositionDiffEntry {
|
||||||
|
/** the value is a secret, so neither value is given */
|
||||||
|
"masked"?: boolean;
|
||||||
|
/** the entry: an environment entry by its name, else the part of the resource that differs */
|
||||||
|
"name": string;
|
||||||
|
/** its value in the other composition; absent where the other lacks it or the value is a secret */
|
||||||
|
"other"?: string;
|
||||||
|
/** its value in the running composition; absent where the running one lacks it or the value is a secret */
|
||||||
|
"running"?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** one resource with the entries of it that differ */
|
||||||
|
export interface CompositionDiffResource {
|
||||||
|
/** the entries of the resource that differ */
|
||||||
|
"entries": CompositionDiffEntry[];
|
||||||
|
/** the resource, as the composition names it */
|
||||||
|
"resource": string;
|
||||||
|
}
|
||||||
|
|
||||||
/** a group */
|
/** a group */
|
||||||
export interface DeclaredGroup {
|
export interface DeclaredGroup {
|
||||||
"gid": number;
|
"gid": number;
|
||||||
@@ -963,6 +984,29 @@ export interface CompositionAnswer {
|
|||||||
"withheld-unknown"?: string;
|
"withheld-unknown"?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** is what composition-diff takes. */
|
||||||
|
export interface CompositionDiffInput {
|
||||||
|
/** the digest (sha256:…) of the composition to compare with; give it or revision */
|
||||||
|
"digest"?: string;
|
||||||
|
/** the module, as placed on this machine; node for the node's own */
|
||||||
|
"module": string;
|
||||||
|
/** the revision of the module's composition key to compare with, from the revisions the bucket keeps; give it or digest */
|
||||||
|
"revision"?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** is what composition-diff answers. */
|
||||||
|
export interface CompositionDiffAnswer {
|
||||||
|
/** the module */
|
||||||
|
"module": string;
|
||||||
|
/** the node */
|
||||||
|
"node": string;
|
||||||
|
"other"?: Revision;
|
||||||
|
/** each resource with an entry that differs; empty when none differs */
|
||||||
|
"resources": CompositionDiffResource[];
|
||||||
|
/** the digest of the composition that runs; absent when nothing runs */
|
||||||
|
"running"?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/** is what compose takes. */
|
/** is what compose takes. */
|
||||||
export interface ComposeInput {
|
export interface ComposeInput {
|
||||||
/** a module placed on this machine whose apply is also tried again (optional) */
|
/** a module placed on this machine whose apply is also tried again (optional) */
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const verbs = {
|
|||||||
acts: "acts",
|
acts: "acts",
|
||||||
packages: "packages",
|
packages: "packages",
|
||||||
composition: "composition",
|
composition: "composition",
|
||||||
|
compositionDiff: "composition-diff",
|
||||||
compose: "compose",
|
compose: "compose",
|
||||||
composeCandidate: "compose-candidate",
|
composeCandidate: "compose-candidate",
|
||||||
manifestReads: "manifest-reads",
|
manifestReads: "manifest-reads",
|
||||||
|
|||||||
Reference in New Issue
Block a user