Review round 1: a durable whose twin is current was removed without reading the durable itself, so of the five live pairs where both twins have pulls waiting either one would have gone. The tool now reads the named durable too and refuses it while pulls wait on it, both read from the bus at the call. "Current" is the setting twin-current-hours (24 by default) of the manifest, read from the configuration at each call, the field name the grants part's manifest names too. Builds: design 47 H2 H-A-472 (1) and its third addendum (1), (2); review round 1 findings (1), (2)
449 lines
11 KiB
JSON
449 lines
11 KiB
JSON
{
|
|
"module": "nats",
|
|
"version": "0.1",
|
|
"class": "core",
|
|
"packages": {
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-grants/busgrants": "0.1"
|
|
},
|
|
"upgrade": {
|
|
"policy": "record",
|
|
"why": "the bus keeps the streams of the whole mesh: each move waits for a person's yes, which the operator's Approve of the release that carries its build gives, and its node backs its streams up before it applies (hq ADR 0236, ADR 0601)"
|
|
},
|
|
"provides": [
|
|
{
|
|
"name": "mesh-bus",
|
|
"scope": "mesh",
|
|
"credential": {
|
|
"form": "none"
|
|
}
|
|
},
|
|
{
|
|
"name": "bus-state",
|
|
"scope": "mesh",
|
|
"credential": {
|
|
"form": "none"
|
|
}
|
|
}
|
|
],
|
|
"claims": [
|
|
{
|
|
"name": "mesh-broker",
|
|
"scope": "mesh",
|
|
"serves": [
|
|
"list",
|
|
"show",
|
|
"check",
|
|
"orphans",
|
|
"snapshot-get",
|
|
"snapshot-restore",
|
|
"snapshot-restore-cancel",
|
|
"snapshot-remove"
|
|
]
|
|
}
|
|
],
|
|
"bus-users": "/var/lib/nats-module/conf/accounts.conf",
|
|
"core-credentials": true,
|
|
"own-secrets": {
|
|
"broker": "${dir:mesh-state}/broker",
|
|
"broker-nats-tools": "${dir:tools-secret}/broker-nats-tools",
|
|
"broker-keeper": {
|
|
"path": "${dir:keeper-state}/broker-keeper",
|
|
"owner": "nats-keeper"
|
|
}
|
|
},
|
|
"capabilities": [
|
|
"container-runtime"
|
|
],
|
|
"emits": [
|
|
"consumer-removed",
|
|
"bucket-keys-removed",
|
|
"stream-removed",
|
|
"stream-purged",
|
|
"bucket-expiry-set",
|
|
"snapshot-restored"
|
|
],
|
|
"invokes": [
|
|
"seat:mesh-hand-acts.hand-act",
|
|
"seat:mesh-catalog.revision",
|
|
"seat:mesh-catalog.registrations",
|
|
"seat:mesh-delivery.source",
|
|
"seat:mesh-catalog.seat-definitions"
|
|
],
|
|
"consumes": [
|
|
"mesh-catalog.catalog-revision",
|
|
"mesh-catalog.registration-changed",
|
|
"mesh-delivery.source-moved",
|
|
"mesh-catalog.seat-definition-changed",
|
|
"mesh-catalog.seat-definition-removed",
|
|
"mesh-conditions.findings-asked"
|
|
],
|
|
"uses": [
|
|
"operator-channel"
|
|
],
|
|
"config": {
|
|
"snapshots-cap": {
|
|
"type": "number",
|
|
"description": "How many bytes the keeper's snapshots directory may hold (design 47 G §681): past 80 % of it the keeper tells a finding, and it never takes a snapshot past it. The keeper reads it at its start from its settings file.",
|
|
"minimum": 1,
|
|
"default": 21474836480
|
|
},
|
|
"snapshot-keep-days": {
|
|
"type": "number",
|
|
"description": "How many days a snapshot the keeper took before a drop or recreate, and its record, are kept (design 47 G §681, A-112). The keeper reads it at its start from its settings file; the tool nats_snapshots reads it as its configuration.",
|
|
"minimum": 1,
|
|
"default": 90
|
|
},
|
|
"twin-current-hours": {
|
|
"type": "number",
|
|
"description": "How many hours since a module's durable's twin last delivered it is current (design 47 H2, H-A-472): nats_consumer_remove removes a module's durable with no pulls waiting only while its twin has pulls waiting and a delivery within these hours. The grants part's manifest names the same setting for its orphaned durables. The tool reads it as its configuration at each call.",
|
|
"minimum": 1,
|
|
"default": 24
|
|
}
|
|
},
|
|
"streams": [
|
|
{
|
|
"name": "broker-events",
|
|
"events": [
|
|
"created",
|
|
"refused",
|
|
"drifted",
|
|
"drift-cleared",
|
|
"full",
|
|
"full-cleared",
|
|
"orphaned",
|
|
"recreated",
|
|
"dropped"
|
|
],
|
|
"retention": "history",
|
|
"max-mib": 256
|
|
},
|
|
{
|
|
"name": "nats-findings",
|
|
"events": [
|
|
"finding-written.*",
|
|
"finding-cleared.*",
|
|
"findings-stated.*"
|
|
],
|
|
"max-age-days": 7,
|
|
"max-mib": 16
|
|
}
|
|
],
|
|
"state": [
|
|
{
|
|
"name": "asked",
|
|
"history": 5
|
|
},
|
|
{
|
|
"name": "requests",
|
|
"history": 5,
|
|
"ttl-seconds": 7862400
|
|
},
|
|
{
|
|
"name": "spent",
|
|
"history": 1,
|
|
"ttl-seconds": 86400,
|
|
"read-only": true
|
|
},
|
|
{
|
|
"name": "plans",
|
|
"history": 1,
|
|
"read-only": true
|
|
},
|
|
{
|
|
"name": "findings",
|
|
"history": 1
|
|
}
|
|
],
|
|
"listens": [
|
|
{
|
|
"name": "bus",
|
|
"port": 4222,
|
|
"protocol": "tcp",
|
|
"from": "mesh",
|
|
"why": "the mesh bus \u2014 every link the mesh has, over TLS, reached across the overlay"
|
|
}
|
|
],
|
|
"tools": [
|
|
"nats_server",
|
|
"nats_connections",
|
|
"nats_closed_connections",
|
|
"nats_subscriptions",
|
|
"nats_streams",
|
|
"nats_backlog",
|
|
"nats_consumer",
|
|
"nats_consumers",
|
|
"nats_stream_messages",
|
|
"nats_buckets",
|
|
"nats_users",
|
|
"nats_user_can",
|
|
"nats_snapshot_verify",
|
|
"nats_consumer_remove",
|
|
"nats_bucket_remove",
|
|
"nats_stream_remove",
|
|
"nats_stream_purge",
|
|
"nats_bucket_expiry",
|
|
"nats_history",
|
|
"nats_create",
|
|
"nats_apply",
|
|
"nats_recreate",
|
|
"nats_drop",
|
|
"nats_keeper_health",
|
|
"nats_first_view_again",
|
|
"nats_requests",
|
|
"nats_snapshots",
|
|
"nats_plans"
|
|
],
|
|
"guards": [
|
|
8222
|
|
],
|
|
"data": {
|
|
"own": [
|
|
{
|
|
"id": "jetstream",
|
|
"path": "${dir:jetstream-data}",
|
|
"class": "valuable",
|
|
"active": "1d",
|
|
"backup": {
|
|
"dump": "p=${dir:snapshots}/bus.tar.partial; s=0; docker exec -i mesh-broker-nats /opt/mesh/mesh-nats-snapshot snapshot < ${dir:mesh-state}/broker > \"$p\" || s=$?; if [ $s -ne 0 ]; then echo \"mesh-nats-snapshot snapshot exited $s$([ $s -eq 137 -o $s -eq 143 ] && echo ' (killed by a signal)')\" >&2; docker inspect -f 'container {{.State.Status}} since {{.State.StartedAt}}' mesh-broker-nats >&2; rm -f \"$p\"; exit $s; fi; mv \"$p\" ${dir:snapshots}/bus.tar || exit 1",
|
|
"into": "snapshots"
|
|
},
|
|
"why": "the bus's streams and key-value buckets: the hand-act log, conditions, every module's state; written all the time, so copied by the server's own snapshot of each stream (novox/hq ADR 0235), never as live files"
|
|
},
|
|
{
|
|
"id": "snapshots",
|
|
"path": "${dir:snapshots}",
|
|
"class": "rebuildable",
|
|
"why": "last night's snapshot of every stream with its manifest, made again every night"
|
|
}
|
|
]
|
|
},
|
|
"resources": [
|
|
{
|
|
"id": "keeper-account",
|
|
"type": "user",
|
|
"name": "nats-keeper",
|
|
"shell": "/usr/bin/nologin",
|
|
"home": "/var/lib/nats-keeper"
|
|
},
|
|
{
|
|
"id": "jetstream-data",
|
|
"type": "directory",
|
|
"path": "/var/lib/mesh-broker-nats",
|
|
"mode": "0700",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "conf-dir",
|
|
"type": "directory",
|
|
"path": "/var/lib/nats-module/conf",
|
|
"mode": "0700",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "tools-secret",
|
|
"type": "directory",
|
|
"path": "/var/lib/mesh/nats-tools",
|
|
"mode": "0711",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "keeper-state",
|
|
"type": "directory",
|
|
"path": "/var/lib/nats-keeper",
|
|
"mode": "0700",
|
|
"owner": "nats-keeper",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "snapshots",
|
|
"type": "directory",
|
|
"mode": "0700",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "mesh-state",
|
|
"type": "directory",
|
|
"mode": "0700",
|
|
"place": "mesh",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "keeper-settings",
|
|
"trusted": false,
|
|
"type": "file",
|
|
"path": "${dir:keeper-state}/settings.json",
|
|
"mode": "0600",
|
|
"owner": "nats-keeper",
|
|
"takes-config": [
|
|
"snapshots-cap",
|
|
"snapshot-keep-days"
|
|
],
|
|
"merge": "json",
|
|
"template": "files/settings.json"
|
|
},
|
|
{
|
|
"id": "server-conf",
|
|
"type": "file",
|
|
"path": "/var/lib/nats-module/conf/nats.conf",
|
|
"template": "files/nats.conf",
|
|
"mode": "0644"
|
|
},
|
|
{
|
|
"id": "state",
|
|
"type": "directory",
|
|
"mode": "0700",
|
|
"place": ".",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "program-snapshot",
|
|
"type": "archive",
|
|
"path": "${dir:state}/snapshot",
|
|
"artifact": "snapshot",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "program-entrypoint",
|
|
"type": "archive",
|
|
"path": "${dir:state}/entrypoint",
|
|
"artifact": "entrypoint",
|
|
"unknown": "program"
|
|
},
|
|
{
|
|
"id": "keeper",
|
|
"type": "process",
|
|
"name": "nats-keeper",
|
|
"artifact": "tools",
|
|
"run": [
|
|
"./nats-tools",
|
|
"keep"
|
|
],
|
|
"user": "nats-keeper",
|
|
"env": {
|
|
"MESH_BROKER_FILE": "${dir:keeper-state}/broker-keeper",
|
|
"MESH_NATS_FULL_RAISE": "75",
|
|
"MESH_NATS_FULL_CLEAR": "70",
|
|
"MESH_NATS_SNAPSHOTS_DIR": "${dir:keeper-state}"
|
|
},
|
|
"serves": [
|
|
"seat:mesh-broker.snapshot-get",
|
|
"seat:mesh-broker.snapshot-restore",
|
|
"seat:mesh-broker.snapshot-restore-cancel",
|
|
"seat:mesh-broker.snapshot-remove"
|
|
],
|
|
"bus": {
|
|
"state": [
|
|
"asked",
|
|
"requests",
|
|
"spent",
|
|
"plans",
|
|
"findings"
|
|
],
|
|
"asks": true,
|
|
"keeps": true,
|
|
"invokes": [
|
|
"seat:mesh-catalog.revision",
|
|
"seat:mesh-catalog.registrations",
|
|
"seat:mesh-delivery.source",
|
|
"seat:mesh-catalog.seat-definitions",
|
|
"seat:mesh-hand-acts.hand-act"
|
|
]
|
|
},
|
|
"health": {
|
|
"kind": "tool",
|
|
"tool": "nats_keeper_health",
|
|
"interval": "60s",
|
|
"timeout": "10s",
|
|
"looks": 2,
|
|
"grace": "180s"
|
|
}
|
|
},
|
|
{
|
|
"id": "server",
|
|
"type": "container",
|
|
"name": "mesh-broker-nats",
|
|
"ports": [
|
|
"4222:4222",
|
|
"127.0.0.1:8222:8222"
|
|
],
|
|
"volumes": [
|
|
"/var/lib/mesh-broker-nats:/data",
|
|
"/var/lib/nats-module/conf:/etc/nats:ro",
|
|
"${access:tls}:/tls:ro",
|
|
"${dir:state}/snapshot:/opt/mesh:ro",
|
|
"${dir:state}/entrypoint:/opt/mesh-entrypoint:ro"
|
|
],
|
|
"args": [
|
|
"sh",
|
|
"/opt/mesh-entrypoint/entrypoint.sh"
|
|
],
|
|
"artifact": "server",
|
|
"restart-on": [
|
|
"program-snapshot",
|
|
"program-entrypoint"
|
|
],
|
|
"health": {
|
|
"kind": "tcp",
|
|
"endpoint": "bus"
|
|
}
|
|
}
|
|
],
|
|
"accesses": [
|
|
{
|
|
"id": "tls",
|
|
"path": "/var/lib/mesh-broker-tls",
|
|
"mode": "read"
|
|
}
|
|
],
|
|
"build": {
|
|
"artifacts": [
|
|
{
|
|
"name": "server",
|
|
"kind": "upstream",
|
|
"from": "nats:2.11.17-alpine@sha256:e4bf19f15fd3218814a4e3c9e0064e1334bd8aa20d5984b9f1a0afd084f8cc00"
|
|
},
|
|
{
|
|
"name": "snapshot",
|
|
"kind": "bundle",
|
|
"language": "go",
|
|
"system": "alpine",
|
|
"from": "cmd/mesh-nats-snapshot",
|
|
"binary": "mesh-nats-snapshot"
|
|
},
|
|
{
|
|
"name": "entrypoint",
|
|
"kind": "archive",
|
|
"from": "program"
|
|
},
|
|
{
|
|
"name": "tools",
|
|
"kind": "bundle",
|
|
"language": "go",
|
|
"system": "arch",
|
|
"from": "cmd/nats-tools",
|
|
"binary": "nats-tools",
|
|
"loads": [
|
|
"nats-tools"
|
|
],
|
|
"bus": {
|
|
"removes": [
|
|
"controller-leftovers"
|
|
]
|
|
},
|
|
"env": {
|
|
"MESH_NATS_MONITOR": "http://127.0.0.1:8222",
|
|
"MESH_NATS_CONTAINER": "mesh-broker-nats",
|
|
"MESH_NATS_USERS_FILE": "/etc/nats/accounts.conf",
|
|
"MESH_NATS_SNAPSHOTS_DIR": "${dir:snapshots}",
|
|
"NATS_TOOLS_CREDENTIAL": "${dir:tools-secret}/broker-nats-tools"
|
|
}
|
|
},
|
|
{
|
|
"name": "files",
|
|
"kind": "archive",
|
|
"from": "files"
|
|
}
|
|
]
|
|
}
|
|
}
|