Verify that the device's factory-default configuration boots cleanly and
that the device remains usable afterwards -- i.e. it does not fall back to
the fail-secure failure-config.
The test exercises the device's own first-boot bootstrap path: it clears
the startup-config and reboots with the test-mode startup override set, so
confd initialises running from the factory-config (its first-boot path).
That mirrors a factory-fresh / factory-reset device and avoids applying a
full config swap over the live management session -- confd cannot replace
the whole running datastore from within an RPC without timing out, and a
factory config may reconfigure the very transport we are connected over.
The test is image-generic, using whatever factory-config the running image
was built with, so it covers both the stock Infix factory config and any
spin factory config. A single-node (1x1) topology is used on purpose: a
factory config is not written with a lab full of peers in mind, so booting
it across a multi-node topology could trigger broadcast storms or similar.
NETCONF only, as it is the one management transport present in every
factory config.
Signed-off-by: Richard Alpe <richard@bit42.se>
Finishes the migration started in 63f46d4d: setup-mkdocs was still
referenced via a relative ./.github/actions path, which GitHub resolves
against the calling repo, not infix, breaking spins (e.g. Styx) that
reuse build.yml/build-release.yml. Use kernelkit/actions/setup-mkdocs@v1.2.
Signed-off-by: Richard Alpe <richard@bit42.se>
The test-report target fed a pre-baked report.adoc to asciidoctor-pdf.
Let 9pm's report.py, the author of result.json, both generate and
render the report instead. It is invoked with Infix's own theme, fonts
and logo so the output is unchanged; downstream projects need only
override LOGO to rebrand it.
Signed-off-by: Richard Alpe <richard@bit42.se>
The 'command' leaf is config, with a strict pattern that doesn't allow
'&', quotes or pipes. Yanger was populating it from podman's full,
untruncated container command -- so any container whose entrypoint
uses shell metacharacters (e.g. sh -c "... && ...") failed YANG
validation.
The symptom: every operational read of /infix-containers:containers
returns SR_ERR_INTERNAL, which in turn fails the whole get-data on
the operational datastore. This breaks case/misc/operational_all and
any RESTCONF/NETCONF read that touches containers.
This was introduced in 59028c4 ("Fix #1466: 'show container' shows no
output"), which added the operational, pattern-less 'cmdline' leaf
but left the old 'command' assignment in place. Drop it -- 'cmdline'
already carries the full command line, and 'command' belongs to
running config.
Note: the failure can look intermittent across test runs because
podman storage is persistent. It only triggers once a container with
a bad-pattern command ends up in 'podman ps -a', including stale or
exited leftovers from earlier runs.
Signed-off-by: Richard Alpe <richard@bit42.se>
The cfg.ext4 disk image was created but not formatted because mkfs.ext4
wasn't found. As sbin is not in PATH for an unprivileged user in
Debian.
This caused the VM boot to fail with "No persistent storage found for /cfg".
Signed-off-by: Richard Alpe <richard@bit42.se>
- Remove fixed lengths from Column class
- Add dynamic width calculation to SimpleTable
- Update service table to use new batched printing
Signed-off-by: Richard Alpe <richard@bit42.se>
Replace manual f-string formatting with SimpleTable/Column classes.
This new "framework" handles ANSI colors and padding. Removing the
hassle of manually calculating padding. You simply specify the header
with max number of chars the data can be and if you want left/right
padding and the "framework" calculates the padding for you.
We use this new "framework" to pretty print the newly added services
statistics.
Signed-off-by: Richard Alpe <richard@bit42.se>
Add statistics container to service model with memory usage, uptime,
and restart count tracking.
Updates YANG revision to 2025-12-02.
Signed-off-by: Richard Alpe <richard@bit42.se>
Store historical snapshots as compressed .json.gz files to reduce disk
usage. The operational.json file remains uncompressed for easy access.
Signed-off-by: Richard Alpe <richard@bit42.se>
Dump operational datastore to timestamped JSON snapshots every 5 minutes
(in /var/lib/statd/). The operational.json symlink always points to the
latest snapshot.
Implement hierarchical retention policy that keeps the first snapshot of
each time period (hour/day/week/month/year), providing fine-grained recent
history while preventing unbounded disk usage.
This will allow us to plot / track how the system state evolves as
well as give us somewhat fine-grained info in the case of an event,
such as a crash.
Add unit test simulating months of snapshots to verify retention
behavior using a statd stub that only runs the retention code locally
(unit test)
Signed-off-by: Richard Alpe <richard@bit42.se>
Allow a workflow caller to run pre-build scripts though a workflow
call variable. This is potentially dangerous as code can be injected
here. If for example a malicious actor wants to run there C2 code in
the context of someone else they could perhaps inject it here. I
assume this is protected by the same mecahism as the workflow files
themself. I.e. github users untrusted to the Infix org won't be able
to trigger workflows before being explicitly allowed to do so.
This patch also adds a checkout secret. This allows upstream callers
to fetch there own spin / fork though the infix workflows, if they
provide a checkout token with the correct permissions to do so.
Signed-off-by: Richard Alpe <richard@bit42.se>
Multiple services can have PID 0 when stopped/done, making PID
unsuitable as a unique key. There could also be multiple services with
the same name (I would assume?).
Signed-off-by: Richard Alpe <richard@bit42.se>
This patch adds operational data support for system services. The
data is in a generic format but is intended to be able to represent
finit information (initctl) nicely.
The reason for augmenting this to ietf-system and not to
infix-services is that we consider this generic system information
which is totally disconnected from what ever services infix might
provide.
In this first state we only support pid, name, description and state.
Making the data look something like:
"infix-system:services": {
"service": [
{
"pid": 1185,
"name": "udevd",
"status": "running",
"description": "Device event daemon (udev)"
}]
Signed-off-by: Richard Alpe <richard@bit42.se>
Fix a bug where systems with OSPF enabled on some, but not all,
interfaces would cause the OSPF iterator to fail when accessing
iface['area'], which was missing. This caused the ospf_status.py
tool to return {}, resulting in empty OSPF data in sysrepo.
Fixes#1169 Expected neighbors not shown in sysrepocfg
Signed-off-by: Richard Alpe <richard@bit42.se>
This is currently a standalone workflow that needs manual trigger via
workflow_dispatch, but the end goal here is to chain it to the release
job.
Signed-off-by: Richard Alpe <richard@bit42.se>
This branch can be used to test push events which is especially
useful when working on the CI infrastructure.
Signed-off-by: Richard Alpe <richard@bit42.se>
There are 2 main reasons for this:
1) It's almost impossible to write complex logical expressions in GH
workflows. I wanted to pass "" as flavor when not building _minimal.
So that the end target string would become TARGET + FLAVOR where
FLAVOR is empty, making it x86_64 for example.
As it turns out "" is false in GH workflow logical expressions, this
in conjunction with the limitations the interpreter has made it hard
to actually write sane expressions in the "with:" variables when
calling downstream jobs via workflow calls.
Here's an example of what I was trying to do and could not:
with:
flavor: ${{ (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'ci:main')
) && '' || '_minimal' }}
As '' is false, the first sets of expressions always evaluates to
false making the string "_minimal". I tried bracing this in various
ways and to use "null" or various JSON objects, all in vain.
2) It reduces complexity instead of adding additional.
Signed-off-by: Richard Alpe <richard@bit42.se>
Previously, upgrading Podman containers with the same tag left
behind dangling images, causing overlay storage to grow and fill
disk space.
This change ensures dangling images are cleaned up using
podman image prune. The command is run without -a, so only
unreferenced images are removed. This provides safe cleanup while
preventing unnecessary overlay growth.
Fixes#1098
Signed-off-by: Richard Alpe <richard@bit42.se>
Prior to this commit yanger looked at the running system using
os.path..., this meant that the static reply / capture data wasn't
used properly. This resulted in strange behavior during unit testing
on GitHub runners where USB ports are missing.
Signed-off-by: Richard Alpe <richard@bit42.se>
Redesign how GH actions are triggered. This new design uses a
self-trigger to start jobs which are only started via workflow_calls.
The main benefit of this is to be able to start workflows from various
Infix Spins without needing to duplicate the workflow files in them.
Upcoming patches are intended to parameterize to allow Spins to pass
different architectures, brand names and such.
Signed-off-by: Richard Alpe <richard@bit42.se>
Some CLI commands where inadvertently moved from the global CLI
context into the show context.
For example the upgrade command.
As a result, commands like upgrade were unavailable at the top-level
prompt:admin@ix-00-00-00:/> upgrade ?
Error: Command not found, or incomplete.
However, these commands remained accessible under the "show" context
as a temporary workaround:
admin@ix-00-00-00:/> show upgrade ?
URI [(ftp|tftp|http|https|ftp)://(dns.name | ip.address)/path/to/]upgrade-bundle.pkg
This patch restores the affected commands to the global CLI context so
that commands like upgrade function as intended at the root prompt.
Fixes: 9c0a8e39 klish-plugin-infix: fix indentation in infix.xml
Signed-off-by: Richard Alpe <richard@bit42.se>
Non-privileged users in the sys-cli group can now access sysrepo data.
The data is now solely protected by the NCAM rules and not Unix file
permissions. Any stray user that's not part of the (default) sys-cli
group still can't access syrepo, like users added from the shell.
Fixes#932
Signed-off-by: Richard Alpe <richard@bit42.se>
Use new buildroot branching strategy where all our commits are placed
on top of a buildroot release on a branch named BR_RELEASE-kkit.
Signed-off-by: Richard Alpe <richard@bit42.se>
This allows a user to run in on any system which has the Infix source
code that contains the modification scripts.
Signed-off-by: Richard Alpe <richard@bit42.se>
The software list from sysrepo is no longer reversed, the reverse now
happens in cli-pretty. This commit reflects that.
Signed-off-by: Richard Alpe <richard@bit42.se>
The reason for this is:
1) We want to use the same fetch tool for all operational data, to
avoid having duplicated xpaths scattered across the repo.
2) We want to call this directly from the CLI, which means it need to
be escape safe. A unprivileged user shall be able to use it but not
escape into a shell or do other malicious stuff.
Signed-off-by: Richard Alpe <richard@bit42.se>
There's several reasons for this. The main reason is that it was
developed as an intermediate way of getting system information when
the operational datastore was almost empty. There's not a lot of data
available in the operational datastore and we shall rely on that data
primarily. This command isn't safe to run from a jailed CLI as i
doesn't validate input and run commands directly in the shell, making
it hard to protect against a CLI jail break.
In upcoming patches we will introduce a new show tool that relies
solely on operational data and which sanitize the user input.
Signed-off-by: Richard Alpe <richard@bit42.se>
The code assumes both SRC and DST is passed, here we ensure this
early.
Prior to this patch:
root@host:~$ copy foo
Segmentation fault (core dumped)
Signed-off-by: Richard Alpe <richard@bit42.se>
Prior to this patch the errno value was overwritten by getgrgid()
making the printouts invalid:
Error: setting group owner wheel (10) on /cfg/startup-config.cfg:
Success
Signed-off-by: Richard Alpe <richard@bit42.se>
Avoid a theoretical race between getting the number of groups a user
belongs to and actually processing them. We should not need to check
the return value of getgrouplist() as we know the number of groups fit
inside the buffer.
Signed-off-by: Richard Alpe <richard@bit42.se>
{topdoc} is needed for asciidoctor to find the image during test
report generation.
This is the same functional change as 02d8288863 but with the
generation script actually updated. This was forgotten in the last
commit.
Signed-off-by: Richard Alpe <richard@bit42.se>
This should be a non functional change. The idea is to use the topdoc
dir from 9pm when generating the test report.
Signed-off-by: Richard Alpe <richard@bit42.se>
Make show interfaces container aware. This is done by looking though
all podman containers for interfaces and looking up there info from
network namespaces on the main system / hypervisor.
Interfaces controlled by containers are clearly marked in the "show
interfaces" output, with a single gray row. Telling the user that they
belong to one or more named containers. The user can then run "show
interface name NAME" on interfaces owned by containers, which provided
some additional info, such as mac address and stat counters.
The patch also add support for printing veth peers which are owned by
containers.
Lastly, the patch also adds test cases for this functionality.
Signed-off-by: Richard Alpe <richard@bit42.se>
Fix a double free in the memory minefield surrounding container
hostname provisioning. The hostnamefmt() function already does free()
on success.
This caused all sorts of mayhem when working with multiple containers.
However it mainly manifested itself by some containers not starting
due to there activation script being polluted with gibberish
name data. Your symptom might be different..
Example of polluted activation script:
container --hostname foobar --net veth0k -r always \
create ^S@`M-}^G docker://ghcr.io/kernelkit/curios:edge
Signed-off-by: Richard Alpe <richard@bit42.se>