Ask the packet filter's holder allowed at every compose of the filter
The node-engine stays the one renderer of the filter file: at each compose of a converged node's filter it asks the holder of node-packet-filter its verb allowed within the setting compose-ask-bound (10 s) and renders the answer. When allowed does not answer, or answers what is not its answer, no filter file is composed: the one loaded is kept as it runs, the holder's module is not held (an old holder must stay replaceable), and the part withheld is said once in the journal until an answer comes between. The node hears allowances-changed on its own node's subject and composes again. The manifest invokes seat:node-packet-filter.allowed and consumes node-packet-filter.allowances-changed. Builds: design 08 control-verbs §1, §3, §4, §5, §7, §8; ADR 0683; H-A-305, H-A-307 (1), (2), H-A-314 (3), (5), (7), H-A-315 (2), (6), H-A-321
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-networking/modules/mesh-connectivity-contracts/go/seats/nodepacketfilter"
|
||||
"git.novox.be/novox/mesh-sdk/go/declaration"
|
||||
"github.com/novox/mesh-host/internal/buckets"
|
||||
"github.com/novox/mesh-host/internal/compositions"
|
||||
@@ -145,6 +146,13 @@ type Env struct {
|
||||
// Set, the composer reads the catalog half by the fingerprints its wants and the runnings it heard name and nothing else of
|
||||
// the indexer's or the builder's states (design 47 G §421, §628); a composer is made with it.
|
||||
Entry meshcatalogclient.Call
|
||||
// Allowed asks the holder of the seat node-packet-filter on this node its verb allowed, within the bound given, in the
|
||||
// engine's own name: the allowances a compose of the filter renders (design 08 control-verbs §1). Nil asks nothing, and
|
||||
// the filter renders none.
|
||||
Allowed func(ctx context.Context, within time.Duration) (json.RawMessage, error)
|
||||
// ComposeAskBound is the setting `compose-ask-bound`: how long a compose waits for allowed; DefaultComposeAskBound when 0
|
||||
// (design 08 control-verbs §1, H-A-314 (5)).
|
||||
ComposeAskBound time.Duration
|
||||
// Registry asks the registry seats' verb versions (oci-artifact-registry, container-image-registry) in the engine's own
|
||||
// name: a want naming its version is resolved to its artifacts' digests through it (design 47 G A-430a).
|
||||
Registry meshcatalogclient.Call
|
||||
@@ -328,6 +336,11 @@ type Composer struct {
|
||||
pubSaid string
|
||||
pubWrite sync.Mutex
|
||||
pubKept map[string]ComposedEntry
|
||||
// filter is what the last pass's compose of the packet filter was given (filterOf), which a candidate composed in shadow
|
||||
// is given too; allowedSaid says its withheld allowed was said in the journal, until it answers (design 08
|
||||
// control-verbs §4). Guarded by mu.
|
||||
filter resolution.Filter
|
||||
allowedSaid bool
|
||||
}
|
||||
|
||||
// Pass is how one pass went, as the node-engine's verb compose answers it.
|
||||
@@ -574,24 +587,37 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the node composes again when a secret changes, and cannot hear the vault say so: %w", err)
|
||||
}
|
||||
go func() {
|
||||
defer stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case _, ok := <-heard:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
// And the packet filter's holder saying its allowances changed on this node: the filter is composed again, asking
|
||||
// allowed; the event's body is not rendered (design 08 control-verbs §3).
|
||||
changed, stopChanged, err := c.env.Hear(nodepacketfilter.SubjectAllowancesChanged(c.env.Node))
|
||||
if err != nil {
|
||||
stop()
|
||||
return nil, fmt.Errorf("the node composes its filter again when its allowances change, and cannot hear the holder of %s say so: %w",
|
||||
nodepacketfilter.Seat, err)
|
||||
}
|
||||
for _, h := range []struct {
|
||||
heard <-chan []byte
|
||||
stop func()
|
||||
}{{heard, stop}, {changed, stopChanged}} {
|
||||
go func() {
|
||||
defer h.stop()
|
||||
for {
|
||||
select {
|
||||
case merged <- tagged{in: -1, ok: true}:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case _, ok := <-h.heard:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case merged <- tagged{in: -1, ok: true}:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}
|
||||
if c.env.SeatListChanged != nil {
|
||||
go func() {
|
||||
@@ -662,7 +688,7 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er
|
||||
}
|
||||
switch {
|
||||
case t.in < 0:
|
||||
dirty = true // a secret changed: its new generation is asked of the vault at the compose
|
||||
dirty = true // a secret or the allowances changed: asked again at the compose
|
||||
case t.u.Caught:
|
||||
caught[t.in] = true
|
||||
if ins[t.in].bucket == buckets.Assignments {
|
||||
@@ -1138,6 +1164,11 @@ func (c *Composer) compose(ctx context.Context) []agent.Update {
|
||||
// (ADR 0636 §1): the module is held as it runs before anything of its build is read, so no take-in or artifact
|
||||
// reference of it (the artifact store's seat is not bootstrapped) can refuse the pass (issue 1966).
|
||||
scope.Held = c.heldUntilListed(ctx, r, own)
|
||||
// The packet filter's allowances, asked of its holder at every compose of the filter (design 08 control-verbs §1, §4).
|
||||
scope.Filter = c.filterOf(ctx, own)
|
||||
c.mu.Lock()
|
||||
c.filter = scope.Filter
|
||||
c.mu.Unlock()
|
||||
// A want whose entry the catalog half has not answered, or holds none of, is held with what runs of it (§421).
|
||||
if holds := c.entryHolds(); len(holds) > 0 {
|
||||
if scope.Held == nil {
|
||||
|
||||
Reference in New Issue
Block a user