A minimal second agent — a redundant remote entry point for the control
center. Every node runs it next to the primary yuneta_agent.
The init scripts deliberately leave agent22 alive when stopping the node, so
a remote operator is never stranded if the primary agent is down or being
upgraded (the two agents upgrade each other, never both at once).
It runs in its own systemd unit, yuneta_agent22.service: sudo systemctl restart yuneta_agent22 (or sudo service yuneta_agent22 restart) restarts it
alone. How the two units are started, stopped and deployed is in
yuneta_agent: starting and stopping it.
Control-center link¶
Like the primary agent, agent22 dials the control center when the node has an
owner, but on its own endpoint — __output_url__ defaults to
yunetacontrol.ovh:1989 (port 1989, vs the primary agent’s …com:1988):
tcps://<machine>.<node_owner>.yunetacontrol.ovh:1989It trusts only the control center’s own certificate, as the primary agent does
(see controlcenter). Up to 7.30.3 the port was 1995.
The origin of the runtime of the node¶
The identity card of agent22 says the origin of the runtime of the node
(7.32.6+). The runtime is the libraries, the agents and the yunos that the node
runs. The key runtime_from has one of two values:
| Value | The node | What upgrades its agent |
|---|---|---|
"source" | builds from source: /yuneta/development/yunetas holds kernel/ and .git. This is the test of the preinst of the package. | upgrade-agent |
"package" | runs what its package installed. | install-package |
The package database does not show the difference. Each node that runs the agents has the package installed, and a node that builds from source has it too (see A source node keeps its package).
The control center shows the whole card with list-agents expand=1:
ycommand --url=wss://<control center>:1997 <login options> -c 'list-agents expand=1'This is a part of the card of a package node:
{
"id": "16b087c8-46c2-8d38-8928-ea7a11521ec6",
"yuno_role": "yuneta_agent22",
"os": {
"id": "debian",
"version_id": "13",
"pretty_name": "Debian GNU/Linux 13 (trixie)"
},
"runtime_from": "package",
"development_machine": false
}agent22 reads the value when it starts. After a node changes, the card shows
the new value when agent22 starts again. A package install starts it again
(the postinst does it). After a build from source,
yunetas restart-agents does it. An agent22 before 7.32.6 has no runtime_from in its card.
A development machine¶
A development machine is the computer of a developer. It builds from source,
but it gives no packages to a deploy center (7.32.10+): its tree and its
system change while the developer works. Mark it in the json file of
agent22, /yuneta/agent/yuneta_agent22.json, and then start agent22
again:
"global": {
"Agent22.development_machine": true
}The card of every node of 7.32.10+ has the key development_machine, true
or false. A deploy center reads it and leaves such a node out of its
sources of packages. On a development machine, list-built-packages,
read-built-package, build-package and build-package-status refuse,
with the reason development-machine (see
Reasons of a refusal). The default is false.
Remote consoles (PTY)¶
agent22’s distinctive feature is a remote console facility built on a PTY
(C_PTY, forkpty). The control center can open an interactive console on the
node and stream keystrokes/output to it:
| Command | Parameters | Description |
|---|---|---|
open-console | name, … | Open a PTY console |
write-tty | name, content64 | Write (base64) data to a console’s tty |
list-consoles | — | List open consoles |
close-console | name | Close a console |
upgrade-agent | content64 | Replace the binary of the main agent and restart it (Upgrading the main agent) |
install-package | url, sha256 | Install a yuneta-agent package on a package node (Installing a package) |
install-package-status | lines | How the last install-package went |
list-built-packages | — | The packages that yunetas package made on a source node (Taking a package of a source node) |
read-built-package | file, offset, length | A chunk of one of them, in base64 |
build-package | tag, jobs | Build the package of a source node at a tag (Building a package on a source node) |
build-package-status | lines | How the last build-package goes |
help | — | Command help |
A write-tty that cannot be written is refused, and the link to the control
center stays up:
A
namethat is no open console (a key typed right after the console closed), or a service that is not a console (__yuno__,agent22), logs one WARNING (“console not found”, “not a console”). The requester getsEV_TTY_CLOSEwith thatname, so its terminal can close.A
write-ttywithoutcontent64logs one WARNING (“content64 required”) and is dropped.A
write-ttyof an operator without the permissionopen-console(7.32.5+) logs one WARNING (“write-tty refused: no permission to open-console”, with theusername). The requester getsEV_TTY_CLOSEwith thatname, and the console goes on for its other routes. See Permissions.
write-tty name=nosuch content64=YQ== -> EV_TTY_CLOSE {"name": "nosuch"}
write-tty name=__yuno__ content64=YQ== -> EV_TTY_CLOSE {"name": "__yuno__"}Up to 7.30.26 a console not found and a missing content64 were an ERROR and
an EV_DROP of the whole link to the control center. A service that is no
console was sent the write: __yuno__ answered “Event NOT DEFINED in
state” with a stack, and agent22 wrote to itself. The primary agent does
the same since this version (see yuneta_agent).
A control center that does not read¶
A console has flow control, as the primary agent’s (see
yuneta_agent, Consoles). When the link to the control
center has console_pause_tx_queue messages or more waiting (default 256,
and a message carries up to 1 KB of output, about 2 KB on the wire), or
console_pause_tx_bytes bytes or more (default 1048576, the link’s
cur_tx_bytes), the console stops reading its terminal: its process waits on its write, and nothing is lost. It reads
again when the link has sent everything, or when the link drops its
connection (what it had waiting goes with it). The link is the only route of
agent22’s consoles, and the one that opened them, so it freezes nobody
else: a console waits for it as long as the control center is away, with no
deadline.
console_max_tx_queue (default 8192) and console_max_tx_bytes (default
33554432, 32 MB) stay as a hard bound whatever paused the console (they
matter only with flow control off): over either the console is closed, with
ONE WARNING “console output not taken by its session, console closed for
it” (with tx_queue and tx_bytes). 0 turns any of the four attributes
off:
{
"global": {
"agent22.console_pause_tx_queue": 256,
"agent22.console_pause_tx_bytes": 1048576,
"agent22.console_max_tx_queue": 8192,
"agent22.console_max_tx_bytes": 33554432
}
}The route of a console keeps only what routes its events back of the
request that opened it: the stack of its hops (ievent_gate_stack) and its
__msg_type__. Any other key of the request’s __md_iev__ (a marker of the
control center) does not return with the console’s events. Before the fix
the whole __md_iev__ was kept and copied into every chunk of output, and
the bounds counted messages only: a request padded with 1 MB made every
chunk of 1 KB a message of 1 MB, and 256 of them took agent22 from 11 to
264 MB.
Up to 7.30.26 there was neither: a control center that did not read its link
grew agent22 with all the output of its consoles (some 50 MB/s with yes)
until it aborted. Test: tests/c/c_agent22_write_tty (8 s of yes with the
link not read: agent22 stays flat, and the console goes on when the link is
read again. The same with the request padded with 1 MB: under +25 MB, and
frames of output of 2 KB when the padding is not in a hop).
Upgrading the main agent¶
agent22 replaces the binary of the main agent and restarts it (7.31.27+).
Send the command through the control center to the agent22 of the node:
ycommand --url=wss://<control center>:1997 <login options> -w 120 \
-c 'command-agent agent_id=<node> cmd2agent="upgrade-agent content64=$$(/yuneta/agent/yuneta_agent)"'ycommand reads the file and sends it in base64. Give -w enough seconds
for the binary to arrive, or the answer is lost. A 36 MB binary takes some
20 seconds.
| Parameter | Type | Description |
|---|---|---|
content64 | string | The new yuneta_agent binary in base64. |
The command does these steps:
It writes the binary as
/yuneta/agent/upgrade/yuneta_agent.It runs the binary with
--print-role. If the role is notyuneta_agent, it deletes the binary and refuses the command.It copies the binary that runs from
/proc/<MainPID>/exeofyuneta_agent.serviceto/yuneta/agent/upgrade/running/yuneta_agent. It reads the old version from that copy (7.31.28+).It keeps that copy as
yuneta_agent.bak-pre-<new version>. If that backup is already there, it stays as it is.It renames the new binary over
/yuneta/agent/yuneta_agent.It restarts
yuneta_agent.servicewithsudo -n systemctl restart --no-block.
The answer comes before the main agent is back:
yuneta_agent22^node1: yuneta_agent 7.31.26 -> 7.31.27, the one that
runs kept as /yuneta/agent/yuneta_agent.bak-pre-7.31.27; restart of
yuneta_agent.service queuedThe data of the answer has old_version, old_from (running or disk),
new_version, backup, backup_was_there and restart.
A build on the node replaces /yuneta/agent/yuneta_agent while the agent
runs. So the file on disk can be the new binary already, and only
/proc/<MainPID>/exe is the binary that runs. Up to 7.31.27 the command
kept the file on disk and read the old version from it. After a build, the
backup was the new binary, and the answer said 7.31.27 -> 7.31.27.
If the main agent runs outside its unit, or the copy fails, the command
keeps the file on disk as before (a hard link). It logs a WARNING, and the
answer says the one on disk (NOT the one that runs: see the log).
The yunos of the node do not restart. The unit stops only the main agent.
Each step has a reason:
A yuno does not run under a name that is not its role. So the new binary keeps the name
yuneta_agent, in its own directory. That directory is on the same file system as/yuneta/agent, so therename()is atomic. At no time is the node without a binary.A binary that runs cannot be written to (
ETXTBSY), but it can be renamed over. The running agent keeps its old binary until the restart.The package installs
/etc/sudoers.d/90-yuneta, sosudo -nworks for the useryuneta. The restart stays inside the unit, so systemd and the next boot see the agent.If the main agent runs outside its unit,
agent22does not restart it. The answer says so, and the binary on disk is the new one.
The command refuses a node that runs from a package. It uses the test of the
preinst of the package: /yuneta/development/yunetas has kernel/ and
.git. On a package node, the agent comes in the package. Then the package
database tells the truth about the node.
The permission is upgrade-agent. The role root has every permission,
and the role agent22-upgrade-agent has only this one (see
Permissions).
Before 7.31.27, the answer to a large content64 did not arrive. Each
answer carried the whole command line back, and the control center dropped
the client (see msg_iev_stack_command_line()).
Installing a package¶
On a package node, the agent comes in the yuneta-agent package.
agent22 downloads the package and installs it (7.31.27+). Send the
commands through the control center to the agent22 of the node:
# 1. Read the sha256 of the package from the SHA256SUMS of its release:
# the line of that file name (a release can hold -1 and -2 of a package).
curl -fsSL https://github.com/artgins/yunetas/releases/download/7.31.27/SHA256SUMS \
| awk -v f=yuneta-agent-7.31.27-1-amd64.deb '$2 == f {print $1}'
# 2. Start the install.
ycommand --url=wss://<control center>:1997 <login options> -w 20 \
-c 'command-agent agent_id=<node> cmd2agent="install-package url=https://github.com/artgins/yunetas/releases/download/7.31.27/yuneta-agent-7.31.27-1-amd64.deb sha256=<sha256>"'
# 3. When agent22 is back in list-agents, read the result.
ycommand --url=wss://<control center>:1997 <login options> -w 20 \
-c 'command-agent agent_id=<node> cmd2agent="install-package-status"'A node on Rocky or Red Hat takes the .rpm asset of the same release, and
the line of SHA256SUMS for that .rpm file. Take the line by its whole
file name, not by its end: after a repackage, the release has a -1 and a
-2 of each package, and SHA256SUMS has a line for each. Each release from 7.31.27 on
has SHA256SUMS. For an older release, download the package and run
sha256sum on it.
| Parameter | Type | Description |
|---|---|---|
url | string | The https:// URL of the .deb or .rpm of yuneta-agent. |
sha256 | string | The sha256 of the package, 64 hex digits. |
lines | integer | install-package-status only: the lines of the journal to show (default 40). |
The answer of install-package comes at once, with the name of the unit
that installs the package:
yuneta_agent22^<node>: installing yuneta-agent-7.31.27-1-amd64.deb in the unit
yuneta-install-package-20261120211600. Its postinst restarts the main agent
and then this one: ask install-package-status when this agent is backinstall-package-status gives four things:
result: the end of the last install. It is one of these lines:done <rc>: the package manager ran and ended with<rc>.done 0is a success.download-failed <rc>:curlfailed with the exit code<rc>. For example,63is a file larger than 1 GiB, and28is a server that sent less than 1 KB/s for 2 minutes.sha256-mismatch: the download does not have the sha256 given.not-yuneta-agent <file>: the download is a package, but notyuneta-agent.refused <why>: the unit found no valid data, or nocurl.
It is empty while the install runs.
installed: the version ofyuneta-agentthat the package database has.units: the unitsyuneta-install-package-*that systemd knows.journal: the end of the journal of those units, with the output ofapt-getordnf.
The root part of the install is a program of the package,
/usr/libexec/yuneta/install-package. Root owns it, so yuneta cannot
change it. The install has these steps:
agent22writes the URL and the sha256 in/yuneta/agent/install-package/. It writes only data.agent22runssudo -n /usr/libexec/yuneta/install-package start.The program checks the data again. It refuses a file that is a link. It copies the data to
/var/lib/yuneta/install-package/, a directory of root, and starts the transient unityuneta-install-package-<UTC time>withsystemd-run. It tellsagent22the name of the unit.The unit runs
/usr/libexec/yuneta/install-package run. It downloads the package into/var/lib/yuneta/install-package/download.<random>/withcurl,httpsonly, also on each redirect. The download stops at 1 GiB, and also when the server sends less than 1 KB/s for 2 minutes. After a transient error (a timeout, an HTTP 5xx),curltries 3 more times.If the sha256 of the download is not the one given, the unit deletes the download and stops. Nothing is installed.
If the download is not the package
yuneta-agent(dpkg-deb -forrpm -qp), the unit deletes it and stops.On Debian, the unit runs
apt-get update. Then it installs the package withapt-get install -y(and--force-confold, so the configurations of the node stay). On Red Hat, it runsdnf install -y. Then it deletes the download and writesresultin/var/lib/yuneta/install-package/.The postinst of the package restarts the main agent and then
agent22.
Each step has a reason:
yunetawrites only data, and root checks it. Up to 7.31.29,agent22wrote the script that root ran into/yuneta, whichyunetaowns. Root also downloaded the package there and wrote the result there. Soyunetawas able to put a link in place of a file that root wrote. Now root writes only in its own directory.yunetacan readresultthere, but it cannot create or replace a file there.The install runs in its own unit, out of the cgroup of
agent22. So the postinst can restartagent22, and the install goes on.systemd expands
%and$in the command line of a unit, and a URL can contain both. The option that stops it (--expand-environment=no) is in systemd 254 and later, and Rocky 9 has 252. So the URL goes in a file, and the command lines have only fixed words.The download uses
curlonly. The--https-onlyoption ofwgetapplies only to recursive downloads, sowgetfollows a redirect tohttp. A node withoutcurlis refused.curlis in the base system of every supported distribution, andinstall.shneeds it too.A
curlolder than 8.4 checks--max-filesizeonly against the size that the server announces. So the unit also limits the size of the files thatcurlwrites (ulimit -f).apt-get updatecomes first because an old index asks the mirror for a version that the mirror no longer has, and a new dependency then fails. If the update fails, the install goes on with the index of the node, asinstall.shdoes. A missing dependency then stopsapt-get installwith an error.agent22restarts during the install, and it forgets the install. Soinstall-package-statusreads the result from a file and from the journal.
install-package refuses these cases. Nothing is written and nothing is
started:
A node that builds from source. The preinst of the package refuses it too. Use
upgrade-agentthere.A package with no
/usr/libexec/yuneta/install-package, for example 7.31.29 or before. The answer says to upgrade the package by hand once. Anagent22of 7.31.29 or before has its own script, and it can install a newer package. So this case comes only whenagent22is newer than its package.A URL that does not start with
https://, has a blank, a quote, a backslash, one of[ ] { }, or a control or non-ASCII character, or does not end in the name of a.debor a.rpm.curlreads[ ]and{ }as a pattern and makes one download for each match, sohttps://example.com/[1-1000000000]/yuneta-agent-7.31.29-1-amd64.debis refused. A host given by its IPv6 address (https://[::1]/) is refused too: use its name.A
.debon a node with noapt-getanddpkg-deb, or a.rpmon a node with nodnfandrpm.A node with no
curl.A second install while one runs.
The permission of both commands is install-package. It is equivalent to
root: the package is the one of the URL and the sha256 that the operator
gives, and the scripts of the package run as root. The permission
upgrade-agent is equivalent to root too, where yuneta has sudo.
Taking a package of a source node¶
A node that builds from source makes its own package with
yunetas package. Two commands of agent22 (7.32.9+) give
that package to a deploy center through the control center. The node needs
no inbound port, so a node behind a router works too.
# 1. The packages of the node, newest first.
ycommand --url=wss://<control center>:1997 <login options> \
-c 'command-agent agent_id=<node> cmd2agent="list-built-packages"'
# 2. One chunk of one of them, from offset 0: 8 MiB at most, in base64.
# Ask for the next chunk at offset + length, after this answer.
ycommand --url=wss://<control center>:1997 <login options> \
-c 'command-agent agent_id=<node> cmd2agent="read-built-package file=yuneta-agent-7.32.9-1-amd64-debian-13.deb offset=0"'Send one request at a time. The control center drops a client that has 32
MB of answers waiting (client_max_tx_bytes), and a chunk of 8 MiB is
about 11 MB of base64. A package of 400 MB is about 50 chunks.
agent22 holds this rule too. While the link to the control center holds
8 MiB or more of answers not sent (the cur_tx_bytes of its transport), a
read-built-package is refused with the reason busy, before agent22
reads the file. Send the request again after the answer of the last one:
{
"result": -1,
"comment": "yuneta_agent22^node1: busy, the link still holds 11184982 bytes of an answer to send: ask for one chunk at a time, the next one after its answer",
"data": {"reason": "busy"}
}The log of agent22 says the refusals with one WARNING a minute,
“read-built-package refused (busy)”, with the count of the refusals since
the last one. Up to 7.32.13 agent22 answered each read. The control center
relays each request at once, so a reader that sent them faster than the link
took the answers (the WAN of a board) made agent22 hold some 12 MB for
each answer, with no limit.
| Parameter | Type | Description |
|---|---|---|
file | string | read-built-package only: a name that list-built-packages gives. A name, not a path. |
offset | integer | read-built-package only: the first byte to read (default 0). |
length | integer | read-built-package only: the number of bytes to read, from 1 to 8388608 (default 8388608, 8 MiB). |
list-built-packages gives a list. Each item has the name of the package,
its size in bytes, its mtime in seconds since the epoch, and the sha256 of
its .sha256 file:
[
{
"file": "yuneta-agent-7.32.9-1-amd64-debian-13.deb",
"size": 413724232,
"mtime": 1796036520,
"sha256": "5e533e18a001ac4ac9c7ddb28b4f3df64366116622ab6486cc04e393b3a4144f"
}
]read-built-package gives one chunk, with the size, the mtime and the
sha256 of the whole file. eof is true on the last chunk:
{
"file": "yuneta-agent-7.32.9-1-amd64-debian-13.deb",
"offset": 411041792,
"length": 2682440,
"size": 413724232,
"mtime": 1796036520,
"sha256": "5e533e18a001ac4ac9c7ddb28b4f3df64366116622ab6486cc04e393b3a4144f",
"eof": true,
"content64": "..."
}list-built-packages lists a file when all of these are true:
It is in
/yuneta/development/yunetas/packages/deb/dist/(a.deb) or inpackages/rpm/dist/(a.rpm).yunetas packageputs it there.Its name is
yuneta-agent-<...>-<ID>-<VERSION_ID>.debor.rpm.<ID>-<VERSION_ID>is the target of this node, from its os-release. Examples:yuneta-agent-7.32.9-1-amd64-debian-13.deb,yuneta-agent-7.32.9-1.el9.x86_64-rocky-9.6.rpm.It is a regular file, not a link.
<name>.sha256is beside it, and holds the line ofsha256sum: the sha256, two blanks and the name.
So the list does not show a package that the builder script made by hand
(AMD64.sh gives no target in the name and writes no .sha256), a package
of another target, or a link. The comment of the answer says when such
files are there. read-built-package refuses the same files, and any name
with a /.
Each chunk carries the size and the mtime of the file. If one of them
changes between two chunks, yunetas package made the package again: start
again from offset 0. At the end, compare the sha256 of the bytes with the
sha256 of the answer. The node wrote the .sha256 itself, so this
check finds a transfer that went wrong. It does not prove what the node
built.
Both commands refuse a node that runs from a package, and a
development machine (7.32.10+). Their
permission is read-built-packages. It reads these files only, and it
changes nothing on the node.
Building a package on a source node¶
build-package (7.32.10+) has a node that builds from source make its
package at a tag. Then a deploy center takes the package with
list-built-packages and read-built-package. The node needs no console
and no SSH.
# 1. Start the job. The answer comes at once, with the job_id and the pid.
ycommand --url=wss://<control center>:1997 <login options> \
-c 'command-agent agent_id=<node> cmd2agent="build-package tag=7.32.10"'
# 2. Ask how it goes, when a person wants to know.
ycommand --url=wss://<control center>:1997 <login options> \
-c 'command-agent agent_id=<node> cmd2agent="build-package-status"'The job takes minutes: about 10 on an amd64 server, 40 to 80 on a riscv64 board, and more when the tag changes the external libraries. Ask for the status when a person opens or refreshes a view, not in a loop on a timer.
| Parameter | Type | Description |
|---|---|---|
tag | string | build-package only: the tag to build. Digits and dots, as 7.32.10. It is the version of agent22 or a newer one (see below). |
jobs | integer | build-package only: the jobs of make, 1 to 256, in each step that compiles, the external libraries too. 0 or no value: build_jobs of the json file of agent22 (below), or the default of yunetas (the cores). The job never runs more jobs than build_jobs, or than the cores when build_jobs is 0: a bigger value is cut to it, and the answer says so. |
lines | integer | build-package-status only: the lines of the end of the log, 1 to 1000 (default 40). The answer gives 16 KB of log at most. |
The job runs these steps in /yuneta/development/yunetas. A failure ends the
job, with a reason:
| Step | Name | What it does | Reason of a failure |
|---|---|---|---|
| 1 | check | Makes sure that the tree is clean: no file of the tree or of a submodule changed. A submodule that only points at another commit is not a change, because step 2 moves it to the commit of the tag. | dirty-tree |
| 2 | git | Runs git fetch --tags, checks out the tag (a detached HEAD) and updates the submodules to it. The fetch and the update of the submodules each last build_net_timeout seconds at most. | unknown-tag, step-failed |
| 3 | config | Makes sure that .config is the release configuration (alldefconfig). The job never changes .config. | config-not-release, step-failed |
| 4 | ext-libs | Runs ./extrae.sh && ./configure-libs.sh when the installed external libraries are not those of the tag. ./extrae.sh clones the libraries, and lasts build_net_timeout seconds at most. ./configure-libs.sh compiles them with jobs jobs. It also uses the network, with the limits below. | step-failed |
| 5 | package | Runs yunetas package -y. It builds the SDK from scratch and makes the package and its .sha256 in `packages/<deb | rpm>/dist/`. |
| 6 | projects | Runs yunetas build of the registered projects, in the order of the registry. The step before made outputs/ again without their yunos. | step-failed |
The job builds a tag of the repository, whatever main is at. It leaves
the tree at the tag, with a detached HEAD. To work on the node again, run
git checkout main && git pull --recurse-submodules there. Up to 7.32.11
the job pulled main, and main had to be exactly at the tag. So any
later commit, a documentation one too, stopped the job with
main-not-at-tag.
A job that stops in step 2 after the checkout can leave a submodule at its
old commit. Step 1 of the next job does not count that as a change, and its
step 2 moves the submodule to the commit of its tag. A changed or new file
inside a submodule is a change: the job stops with dirty-tree, and its log
gives the line of git status --porcelain=v2 after the path of the
submodule. For example, sub: ? stray is a new file stray in the
submodule sub. Up to 7.32.13 a submodule at another commit stopped every
next job with dirty-tree, until a person came to the node.
A stash is not a change. When the git configuration of the node sets
status.showStash, git status --porcelain=v2 writes a header line for the
stash, and step 1 does not count it. For example, with this setting and one
stash in the tree, git status --porcelain=v2 writes # stash 1, and the
job goes on to step 2:
git config --global status.showStash trueThe tag that the job builds is the version that the node runs after its
next restart. The build writes the agents in /yuneta/agent, and the
external libraries of the tag install their web server (nginx, openresty)
in /yuneta/bin. So build-package refuses a tag older than the version of
the agent22 that answers, with the reason older-tag, before the job
starts. A tag equal to that version, or newer, builds:
ycommand --url=wss://<control center>:1997 <login options> \
-c 'command-agent agent_id=<node> cmd2agent="build-package tag=7.32.9"'{
"result": -1,
"comment": "yuneta_agent22^node1: tag 7.32.9 is older than this agent22 (7.32.13): build-package takes the node to the version of agent22 or a newer one, never back",
"data": {"reason": "older-tag", "tag": "7.32.9", "running_version": "7.32.13"}
}The versions are compared number by number: 7.32.10 is newer than
7.32.9. Up to 7.32.13 the job built any tag, an older one too, and the
node went back to the agents and the web server of that tag at its next
restart.
build-package-status gives the last job. This is a job that ended well:
{
"job_id": "20261202T082018Z",
"pid": 4182,
"tag": "7.32.10",
"jobs": 4,
"state": "done",
"step": 6,
"step_name": "projects",
"reason": "",
"exit_code": 0,
"started_at": "2026-12-02T08:20:18Z",
"ended_at": "2026-12-02T08:31:02Z",
"package": "yuneta-agent-7.32.10-1-amd64-debian-13.deb",
"file": "yuneta-agent-7.32.10-1-amd64-debian-13.deb",
"size": 413730112,
"mtime": 1796206262,
"sha256": "89e04e8c23063be97d004be10f46e151f0ca0283d9311d297964bb3e42165f52",
"log": [
"=== step 6: projects (2026-12-02T08:30:41Z)",
"...",
"=== done at step 6: projects (2026-12-02T08:31:02Z)"
]
}state is idle (no job ran on the node), running, done or failed.
When the job is done, file, size, mtime and sha256 are the values
that list-built-packages gives for the package. A job that a reboot or a
kill -9 stopped says failed, with the reason job-lost. A job that got
a signal says failed, with the reason stopped.
The job runs as the owner of the agents, in a process of its own (a daemon
of agent22), with a niceness of 10 so that the yunos of the node go first.
Its oom_score_adj is 1000, the highest: when the memory of the node runs
out, the kernel ends a process of the build first, never a yuno. It needs no
sudo. A restart of the agents does not stop it: their units
stop the agent only (KillMode=process), and the yunos of the agent live on
in the same way. The build writes the new agents on disk, but it does not
restart them. To run them, use upgrade-agent for the main agent, or
yunetas restart-agents on the node.
agent22 keeps the files of the job in /yuneta/agent/build-package/:
job.sh (the script, which agent22 carries in its binary), request,
status, pid, lock and job.log. A new job writes over them.
To give a node its own default number of jobs, put build_jobs in the json
file of agent22. Fit it to the memory of the node: a board with 4 GB
builds with 4 jobs. It is also the most jobs that a command can ask for.
Up to 7.32.13 jobs=256 went past it.
The jobs apply to the external libraries too. ./configure-libs.sh
compiles with MAKEFLAGS=-j$(nproc), and the job sets the variable
OMP_NUM_THREADS to the jobs, so nproc gives the jobs. With jobs 0
and build_jobs 0, the job does not set it, and nproc gives the cores.
Up to 7.32.13 step 4 used every core of the node.
The job puts a limit on the network in two ways:
git fetch --tagsandgit submodule update(step 2), and./extrae.sh(step 4, it clones the external libraries), each lastbuild_net_timeoutseconds at most: 7200 (2 hours) by default, 0 for no limit. When a step goes past it, the job stops the step and fails withstep-failed, and its log says “git fetch --tags did not end in 7200 s (build_net_timeout of agent22)”../configure-libs.sh(step 4) also uses the network:git submodule updatefor some libraries, andpip install. That script also compiles, for an hour or more on a board, sobuild_net_timeoutdoes not apply to it. A transfer that stalls ends instead, in each step: git stops a transfer over HTTP or HTTPS that moves less than 1000 bytes per second for 120 seconds (the job sets the variablesGIT_HTTP_LOW_SPEED_LIMITandGIT_HTTP_LOW_SPEED_TIME). pip keeps its own limit: it stops a read that waits more than 15 seconds../configure-libs.shtries a git step four times, with waits of 30, 90 and 180 seconds between them. Then the script fails, and the job fails withstep-failed.
So a network that is down ends the job, and build-package and
upgrade-agent are free again. Up to 7.32.13 a step that hung kept the job
running with no end, and both answered busy. In ./configure-libs.sh, a
transfer that moves 1000 bytes per second or more has no limit of time. A
board on a slow network can need more time for ./extrae.sh:
"global": {
"Agent22.build_jobs": 4,
"Agent22.build_net_timeout": 14400
}build-package refuses before the job starts, with these reasons:
development-machine, package-node, bad-tag (a tag that is not digits
and dots), older-tag (a tag older than agent22), bad-parameter (jobs
out of range), and busy (a job runs).
While a job runs, upgrade-agent refuses with busy too: both write the
main agent on disk.
Reasons of a refusal¶
The commands of the packages (list-built-packages, read-built-package,
build-package, build-package-status) and upgrade-agent give a reason
with a refusal (7.32.10+). The comment is for a person, and its words can
change. A program reads data.reason:
{
"result": -1,
"comment": "yuneta_agent22^node1: this node is a development machine (development_machine of agent22): it gives no packages",
"data": {"reason": "development-machine"}
}| Reason | Commands | Why |
|---|---|---|
no-permission | all five | The operator has no permission for the command. |
development-machine | the four of the packages | The node is a development machine. |
package-node | all five | The node runs from a package. |
no-target | list-built-packages, read-built-package | The os-release of the node gives no ID and VERSION_ID. |
bad-parameter | read-built-package, build-package, build-package-status | A value is out of range: length, offset, jobs or lines. |
not-a-package | read-built-package | The file is not one that list-built-packages gives. |
read-failed | read-built-package | The node cannot read the file. The log of agent22 says why. |
bad-tag | build-package | The tag is not digits and dots. |
older-tag | build-package | The tag is older than the version of agent22. The data also has tag and running_version. |
busy | build-package, upgrade-agent | A build-package job runs. |
busy | read-built-package | The link to the control center holds an answer that is not sent yet (8 MiB or more). |
launch-failed | build-package | agent22 cannot write the job or start it. The log of agent22 says why. |
The steps of a job that failed have reasons of their own, in the table of
the steps above, and job-lost and stopped.
Permissions¶
agent22 has no users or roles of its own. It opens the store of the main
agent as a read-only replica (Authz.master false, authz_service
agent), and its own Authz.initial_load is not applied. So a permission
of agent22 goes in the configuration of the main agent: its json file
(yuneta_agent.json), or its main.c.
| Command | Permission |
|---|---|
open-console, write-tty | open-console |
close-console | close-console |
list-consoles | list-consoles |
install-package, install-package-status | install-package |
upgrade-agent | upgrade-agent |
list-built-packages, read-built-package | read-built-packages |
build-package, build-package-status | build-packages |
help | none |
The main.c of the main agent seeds four roles. Each role grants one
permission of agent22 and nothing else. They are for the account that
deploys the nodes:
| Role | Permission | Since |
|---|---|---|
agent22-install-package | install-package (also install-package-status) | 7.32.5 |
agent22-upgrade-agent | upgrade-agent | 7.32.5 |
agent22-read-built-packages | read-built-packages (list-built-packages and read-built-package) | 7.32.9 |
agent22-build-packages | build-packages (build-package and build-package-status). The tag that it builds is the version of the node after its next restart, so it grants as much as upgrade-agent. | 7.32.10 |
A role grants nothing until a user is linked to it. The user belongs to the node, so the json file of the main agent names it:
"global": {
"Authz.initial_load": {
"users": [
{
"id": "deployer@example.com",
"roles": [
"roles^agent22-install-package^users",
"roles^agent22-upgrade-agent^users",
"roles^agent22-read-built-packages^users",
"roles^agent22-build-packages^users"
]
}
]
}
}Link the user to a role only when the agent that runs has that role. A seed
that names a role that the store does not have is an ERROR at every start.
For example, agent22-read-built-packages comes with the main agent of
7.32.9, and agent22-build-packages with the main agent of 7.32.10. To link
one on a node with an older agent, put the role itself in the json file
too, as it is in the main.c.
Write the key as Authz.initial_load, with the case of the main.c. A
service name matches a key in any case, so authz.initial_load reaches the
same service, but it is another key of the json. It does not join the
main.c: the service gets one of the two keys whole, the one of the file.
Then the roles are not seeded. Make sure that the merge gives one key:
yuneta_agent --config-file=/yuneta/agent/yuneta_agent.json --print-config | grep -i '"authz.initial_load"'
# one line: "Authz.initial_load": {The lists of the json file are added to the lists of the main.c, as a
set, so the file does not repeat the roles. A seed is protected in two
ways only: nobody can delete these roles, and nobody can cut a link that a
seed declares. A command can change the other fields of a role: an
update-node of the store of users (treedb_authzs) changes its
permission too. The change stays after a restart, because the agent
creates a seed that is not in the store, and never writes again a seed that
is there. So when you need to know that a role is as the seed made it, read
it on the node. The store is the service treedb_authzs of the main agent.
Give the service with -S:
ycommand -S treedb_authzs -c 'get-node topic_name=roles node_id=agent22-build-packages'
# "service": "agent22", "permission": "build-packages"A service= inside -c does not choose the service. The command goes to
the main agent itself, and it answers “command not available:
‘get-node’”. The section Addressing a command of
IPC tells how a command finds its
service.
Each command refuses the node that it is not for: install-package refuses a node that
builds from source, and upgrade-agent, list-built-packages,
read-built-package and build-package refuse a node of packages. The
commands of the packages refuse a development machine too. So you can link
the four roles on every node.
The id is the operator that the control center asserts: the sub of the
operator assertion (see controlcenter), which is the
verified email of the login of that user at the control center. A token with
no email is refused there, for example the token of a client credentials
grant.
On the control center that agent22 connects to (see Control-center link
above), the user also needs the permissions
list-agents and command-agent of the service controlcenter.
command-agent has no parameters that restrict it: the user can send any
command to every agent22 of that control center. The roles above decide
which commands of agent22 run. The commands of __yuno__ ask the
per-command authorization of the yuno (enable_command_authz), which is off
by default, so they run for that user too.
Variant¶
The same sources also build yuneta_agent44 (main44.c), a second flavour
of the minimal agent.