Commit fffc85b
* fix(arkime): un-shadow db.pl and make the translation actually run (#3343)
into composable ones, and left the refusal it could not get past open:
Elasticsearch refuses to create a legacy template whose patterns match an
existing composable one, and single-node-replica-default matches "*", so
db.pl could never install or refresh any of Arkime's templates again. On an
Arkime version bump that needed a template upgrade, arkime-init's db.pl would
fail under `set -e`, the done-marker would not be written, and capture and
viewer would wait on it forever.
It was worse than that. arkime-init's command is a YAML `>` folded block
scalar, and a folded scalar joins every run of adjacent non-empty lines with
a single space. The node invocation sat directly under its comment with no
blank line between, so the whole thing rendered as one `fi` line with a
trailing comment:
fi # #3343: translate ... See arkime/composable-templates.js. /opt/arkime/bin/node /opt/arkime/composable-templates.js
composable-templates.js had therefore never once run, and #3346's fix was
inert while still reading as correct in the YAML. bash -n accepts the
result either way and nothing else exercised the rendering.
composable-templates.js gains a `shadow` subcommand, run before db.pl and
restored after: it deletes every composable template that covers an Arkime
index family, stashing each body first, so db.pl has nothing to collide
with. Coverage is decided by Elasticsearch's own simpleMatch glob semantics
rather than by name, so a renamed or second catch-all is shadowed too --
the previous approach of testing one invented probe name missed even
arkime_sessions3-2*, which overlaps arkime_sessions3-* just as hard. The
restore runs in a `finally`, because the shadowed set includes the
replicas catch-all for every template-less index family in the stack and
leaving it deleted would turn one failure into a yellow cluster.
compose.yml wraps db.pl in a bounded three-attempt retry, which covers the
one race a shadow cannot: a template created *while* db.pl runs, by
elasticsearch-setup's catch-all landing mid-run. Both db.pl verbs are safe
to re-run, and the loop exits non-zero without writing the done marker
rather than wedging the deploy permanently.
elasticsearch-setup.sh's comment claimed the catch-all "explicitly
excluded" Arkime, which was never true -- composable templates have no
exclusion syntax, so the "-arkime_..." entries were literal index names
matching nothing. The inert entries are gone and the comment now names the
mechanism that actually works. Its 60s wait for Arkime's legacy template
is kept: it is the common case and needs no shadow/restore cycle, but it
is no longer load-bearing.
Refs #3343
* fix(arkime): keep the template stash out of world-readable /tmp (#3343)
CodeQL flagged js/insecure-temp-file on the shadow file: it was written to a
fixed path directly in /tmp, so anything on the host could have pre-created
it as a symlink or read the stash. The stash holds the full body of every
Arkime template this script deletes from the cluster, so that is worth
closing.
The path stays fixed because the shadow and generate passes are separate
processes that must share it -- a fresh mkdtemp per process would hand each
one its own empty stash and the generate pass would have nothing to restore.
The fix is the permissions instead: the parent directory is created 0700 and
the file 0600, and neither is widened on rewrite. os.tmpdir() honours TMPDIR
and SHADOW_FILE still overrides the location outright.
Asserted in tests/docs/test_3343_fix.py so a later change cannot quietly drop
the modes back to the mkdir/write defaults.
* test(arkime): teach the #3343 stub the routes #3283 added to generate()
Conflict resolution follow-up for the rebase onto main. #3391 (the #3283
retention work) landed in composable-templates.js between this branch being
cut and the rebase, and it widened the contract generate() has with
Elasticsearch: it now installs _ilm/policy/arkime-sessions-30d immediately
before the template that names it, verifies index.lifecycle.name through
_simulate_index, and adopts the arkime_sessions3-* indices already on disk.
The #3343 suite drives the real script against a stub Elasticsearch, so two
of its tests failed on the rebase with an AssertionError naming an
"unexpected" PUT /_ilm/policy/arkime-sessions-30d. No assertion changed --
the stub is what was stale, and it is what had to learn the new routes.
Its _simulate_index answer changes from a canned
{"number_of_replicas": "0"} to a composition of the templates the script
really PUT, which is what Elasticsearch does and what the script's own
post-install verification depends on. That is strictly stronger than what it
replaces: the canned reply reported 0 replicas whatever the script
installed, so a generated template that dropped number_of_replicas would
still have passed. Composed, it fails. Dropping the retention line from
build() now fails 18 tests across both suites rather than passing silently.
The adoption routes answer with an empty index list, so the #3343
assertions stay about templates and the shadow; the adoption contract
itself remains asserted in tests/docs/test_3283_fix.py, which owns it.
Refs #3343, #3283
* test(arkime): drive #3283's adoption from the #3343 stub, and pin the ordering
Follow-up to 7a80c9c, which taught this stub the routes #3283 added. That
commit answered them, but answered _cat/indices with an empty list and
_settings with a constant, so the adoption branch was never actually entered
from this suite -- the routes were registered and dead. tests/docs/
test_3283_fix.py owns the adoption contract and pins it properly; this change
is about the *combined* run, which is what this suite owns.
The stub now models the one field the script reads: a name maps to whatever
index.lifecycle.name it carries, or None for unmanaged. _stubbed() seeds one
unmanaged sessions index, so the functional tests drive the real path, and
put_ilm_policies records the body so the ordering can be asserted rather than
assumed.
New test: the run that restores the catch-all is the same run that installs
arkime-sessions-30d and adopts what predates it, and the policy is installed
before the template that names it. That ordering is the part that breaks
silently -- an index template naming an ILM policy that does not exist yet
fails index creation outright, and Elasticsearch validates it at index
creation rather than here, so nothing upstream would report it.
Non-vacuous, checked by mutating the script and reverting:
* moving ensurePolicy after the template PUT fails the new test
("the policy was installed after the template naming it")
* deleting the adoption loop fails it
("arkime_sessions3-2026.09.01 was not adopted onto the policy: None")
Local: pytest tests/docs/ 521 passed, 1 xfailed (main: 497 passed, same
xfail); test_3343 + test_3283 together 46 passed. scripts/tests unchanged
from main: the same 2 pre-existing test_compose_drift_watch_sweep failures
that fail on a pristine main checkout on this host.
---------
Co-authored-by: CI-fix lane <ci-fix@users.noreply.github.com>
1 parent 81e9ae8 commit fffc85b
4 files changed
Lines changed: 1120 additions & 91 deletions
File tree
- arcane/home/honeypot-init
- analysis
- arkime
- tests/docs
Lines changed: 52 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1556 | 1556 | | |
1557 | 1557 | | |
1558 | 1558 | | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
1585 | 1571 | | |
1586 | 1572 | | |
1587 | 1573 | | |
1588 | | - | |
| 1574 | + | |
1589 | 1575 | | |
1590 | 1576 | | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
1598 | 1592 | | |
1599 | | - | |
1600 | | - | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1601 | 1599 | | |
1602 | 1600 | | |
1603 | 1601 | | |
| |||
1609 | 1607 | | |
1610 | 1608 | | |
1611 | 1609 | | |
1612 | | - | |
1613 | | - | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1614 | 1613 | | |
1615 | 1614 | | |
1616 | 1615 | | |
1617 | 1616 | | |
1618 | | - | |
| 1617 | + | |
1619 | 1618 | | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
1625 | | - | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | 1619 | | |
1633 | 1620 | | |
1634 | | - | |
1635 | | - | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1644 | 1635 | | |
1645 | 1636 | | |
1646 | 1637 | | |
0 commit comments