mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 20:26:33 +00:00
fix(svc-ai): create the node-local model directory on every swarm node
Both roles mount their model cache as a `type: bind` volume, and swarm
rejects a task whose bind source is missing on the node it lands on. Neither
declares a `placement`, so the scheduler may put the container on any node,
while the directory was created by a single task that reached one host. CI
showed the consequence directly:
s1_s1.1 desired=Ready current=Rejected error="invalid mount config for
type "bind": bind source path does not exist:
/var/cache/infinito/core/cache/models/s1"
with the creating task logging exactly one result line, for the manager.
`nfs_prep.yml` already fans directories out across the cluster but gates on
`driver_opts is defined`, which a bind volume never carries, so these two
volumes were never covered by it.
The host list moves into a `node_hosts` lookup rather than an inline
expression, because two roles already spelled the same idea by hand and a
third and fourth were about to. It answers one question - the hosts a
node-local path must exist on - and keeps the swarm group name in one place
per plugin. The call sites use `query()`, since `lookup()` joins several
results into one string and a loop needs the list.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4c66220c50
commit
7d9a63c98b
4 files changed
+85
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import unittest
|
||||
|
||||
from plugins.lookup.node_hosts import SWARM_GROUP, LookupModule, node_hosts
|
||||
|
||||
LOCAL = "localhost"
|
||||
NODES = ["swarm-mgr-01", "swarm-wrk-01", "swarm-wrk-02"]
|
||||
|
||||
|
||||
class TestNodeHosts(unittest.TestCase):
|
||||
def test_every_swarm_node_is_returned(self) -> None:
|
||||
self.assertEqual(
|
||||
node_hosts({"groups": {SWARM_GROUP: NODES}, "inventory_hostname": LOCAL}),
|
||||
NODES,
|
||||
)
|
||||
|
||||
def test_without_the_group_the_local_host_stands_alone(self) -> None:
|
||||
self.assertEqual(
|
||||
node_hosts({"groups": {}, "inventory_hostname": LOCAL}), [LOCAL]
|
||||
)
|
||||
|
||||
def test_an_empty_group_falls_back_to_the_local_host(self) -> None:
|
||||
"""An empty group would otherwise create the path on no host at all."""
|
||||
self.assertEqual(
|
||||
node_hosts({"groups": {SWARM_GROUP: []}, "inventory_hostname": LOCAL}),
|
||||
[LOCAL],
|
||||
)
|
||||
|
||||
def test_absent_groups_are_not_an_error(self) -> None:
|
||||
self.assertEqual(node_hosts({"inventory_hostname": LOCAL}), [LOCAL])
|
||||
|
||||
def test_the_lookup_reads_the_variables_it_is_handed(self) -> None:
|
||||
lookup = LookupModule()
|
||||
lookup._templar = None
|
||||
self.assertEqual(
|
||||
lookup.run(
|
||||
[], {"groups": {SWARM_GROUP: NODES}, "inventory_hostname": LOCAL}
|
||||
),
|
||||
NODES,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user