Patching
Patching installs operating system updates on Linux hosts that use apt
(Debian, Ubuntu) or dnf/yum (RHEL family, Fedora) and on Windows hosts,
through Windows Update (see Windows Updates). One set of
policies and one run covers both. It is built on
jobs: every step is a signed job that the host's agent checks and
runs, with live output, an audit entry and the usual permission checks. The
pages are under Patches in the top bar.
Synology DSM is never patched from here: it is updated through DSM, and its inventory names Synology DSM as the package source although DSM ships dpkg. Hosts that cannot be patched do not appear in the Hosts list.
A host can be patched when its agent has patch in the actions list of its
config.yaml (see Agent installation) and its inventory
has been read, so that the dashboard knows the package manager and the pending
updates (Inventory). When a run finishes, the agent sends its
inventory again at once, so the pending updates on every page follow within
about a minute rather than at the next regular inventory.
How a run works
A patch run is the work for one host. It has up to three steps, each an ordinary job, with the policy's script steps in front of and behind them:
- Dry run (
patch.dryrun). The host simulates the update (apt-get -s,dnf --assumeno) and reports what would be installed, upgraded and removed. Nothing changes on the host. - Apply (
patch.apply). Runs the update non-interactively. Withaptthe run usesupgradein security mode, which takes only packages from security origins, andfull-upgradein all mode, withDEBIAN_FRONTEND=noninteractiveand--force-confold, so configuration files you edited are kept. Withdnfit uses--security,upgrade, or the named packages. Output is streamed to the job's page while it runs. - Restart (
reboot), when the policy asks for it.
Packages put on hold with apt-mark hold are respected: they are shown as held
(on hold on the host), never count as due, and are left out of a run.
A run is waiting, then in steps before the update when the policy has any for the host, then in its dry run, apply and restart, then in steps after the update. Its page names why a run waits: the soak time of the test hosts, an earlier cluster member, an unhealthy cluster, a host that is not connected, the previous stage (or the steps around it) or a full batch.
The apply is never sent before the dry run has finished. If the dry run shows that packages would be removed, the run stops and waits for a confirmation; the run's page lists the packages concerned. Anyone who may approve patches at the customer can confirm it, the person who started the run included; only where the customer requires four-eyes approval must it be someone else.
A run an assistant requested through the MCP server stops there too, whatever its dry run found: its dry run runs at once, and its apply waits for a person to confirm it under Approvals, with the plan beside it.
Patch jobs are held back by the same rules as every job: a customer that requires approval (see Users and Permissions) gets four-eyes approval on applies, a run attached to a maintenance window only starts while the window is open, and alerts of the host are suppressed while the run is in progress. The dry run changes nothing and is exempt from the customer's approval rule.
The finished run records the packages before and after, whether a restart is required, the exit code, the duration and the output. A restart that is still pending after a run is remembered per host and shown on the overview.
Exclusions
An exclusion is a pattern such as postgresql-* or kernel. The dashboard
leaves matching packages out of what it asks for, and the agent applies the
exclusions again, so a host never upgrades an excluded package. Nothing is
written to the host: no apt-mark hold, no pin, no change to
/etc/dnf/dnf.conf. With apt the run names the packages to upgrade;
with dnf the run passes --exclude. A package name given as a pattern is
expanded by the host's simulation first, and the run stops, installing nothing,
when an excluded package would be changed as a dependency of the rest.
A package name cannot end in - or +: apt-get reads those as "remove" and
"install".
A Windows run with a restart policy of always or if_needed restarts the host
only when its config.yaml also allows the reboot action; otherwise the run
reports that a restart is needed and leaves it.
Policies
Patches → Policies holds the rules. A policy belongs to one customer and says which of its hosts it patches, when, and how. The edit dialog has seven tabs: General, Targets, Schedule, Content, Flow, Restart and Approval.
Policies exist for managed customers only. A not managed customer has no scheduled runs; hosts with an agent there can still be patched by hand with Patch now, and the pending updates are shown as live state without an alert (see Managed and not managed).
Targets
A policy takes its hosts from a selection of any number of building blocks, all within the customer:
| Building block | Takes |
|---|---|
| Whole customer | every host with an agent |
| Hosts | the hosts listed |
| Tags | hosts carrying any of the tags, or all of them |
| Clusters | the members of the clusters listed |
| Folders | the hosts in the folders listed |
The selection can be narrowed to Linux or Windows hosts, and exceptions take hosts out of it whatever else selects them. A selection with nothing set selects nothing. Below the selection the dialog shows a live preview: the hosts concerned, their operating system and folder, and which of them another policy with a higher priority keeps.
Priority
A host belongs to exactly one policy. Of the enabled policies that select it, the one with the highest priority (0 to 1000) governs it. At equal priority the more specific selection wins (a host named in the list, then tag, cluster or folder, then the whole customer), and then the older policy. A disabled policy claims nothing: its hosts belong to the next policy that selects them, or to none. The policy list shows the number of hosts each policy governs and a conflict where another policy takes hosts this one also selects.
Schedule
A policy has its own schedule, or points at a maintenance window, or has neither and is only started by hand. It cannot have both a schedule and a window.
A schedule is a start time, a duration (15 minutes to 24 hours) and a time zone, repeated:
| Repeat | Opens |
|---|---|
| Daily | every day |
| Weekly | on the chosen weekdays, optionally every 2nd to 8th week (counted from fixed weeks, so every second week is always the same weeks) |
| Day of the month | on the 7th, say; a month without that day (the 31st in April) takes its last day |
| Weekday of the month | on the 1st, 2nd, 3rd, 4th or last Wednesday, say; a 5th weekday that a month does not have is skipped |
The start stays on the clock of the time zone through the change to summer time; a time the clock skips that night starts an hour later. The dialog lists the next three starts, and so does the policy list.
When a schedule opens, the policy plans a run for each host it governs that has something due. The jobs of the run expire when the schedule closes, and the host's alerts are suppressed while the run works, as for any job that asks for it. A run that is still waiting for its turn when the occurrence ends is dropped; the next occurrence plans it again.
What is installed
| Setting | Meaning |
|---|---|
| What | security or all, the exclusions, and for Windows hosts the update types (categories: security, critical and rollup by default; drivers and definition updates only when ticked). Exclusions are package patterns and apply to Linux hosts only; a Windows update is not named by a pattern, so Windows hosts follow the update types. |
| Approval | Whether updates start by themselves (auto) or wait until somebody approves them (manual), set separately for security updates (default auto) and for everything else (default manual). |
| Delay | Only packages whose candidate version has been available for this many days are installed: 0 days for security updates and 3 days for others by default. The age counts from the moment the dashboard first saw that version on the host. |
| Restart | never, if_needed (default) or always. The restart is a reboot job inside the run's window or occurrence. There is no fixed restart time. A host of the policy that has nothing due but reports that it needs a restart (for example after unattended-upgrades) gets a run that only restarts it, shown as Reboot only; not with never and not in dry-run-only mode. |
| Dry run only | The run ends after the dry run: it shows what would be installed and changes nothing. Useful when moving a schedule over from another tool. |
Flow
Stages split the hosts of a policy into groups that run one after the other. A stage takes a part of the policy's hosts (listed hosts or tags); a host belongs to the first stage that takes it, and the stage without a selection takes all the rest. Without stages every host is in one stage. Hosts that no stage takes run after the last one. Within a stage the hosts run in parallel, or in batches of N: at most N at the same time.
A stage starts when every host of the stage before it has finished, after the stage's wait (minutes). With only if all succeeded on a stage, the later stages are skipped (Skipped because an earlier stage failed) when a host of this one failed. Cluster members stay in turn within their stage (see Rolling).
Steps run a script of the script library before or after the update:
- A step with no host of its own runs on every host of the stage: before the dry run of that host, or after its apply and restart. The steps of a host run one after another; a failing step fails the run (A step before/after the update failed). Steps after the update are left out when the run changed nothing.
- A step with a host of its own runs once on that host, before the stage starts or after its last host has finished (and only if the stage changed something). The steps are started together. A failing step before the stage skips the stage's hosts (Skipped because a step before the stage failed); the next stage waits for the steps after a stage to finish.
A step runs as an ordinary script.run job with the signature and permission
checks of the library, as the account that created the policy: that
account needs the script.run permission at the customer, and where the
customer requires four-eyes approval the script version has to be approved
already. A script cannot be given values here, so its parameters need
defaults.
Patroni clusters. Restarting the leader of a Patroni cluster is a failover.
The library script Patroni: switchover before restart (Linux) avoids it:
when the host is the leader it runs patronictl switchover to the running
replica with the smallest lag and waits until the host itself is a replica;
on any other member it does nothing and succeeds. Add it as a step before
the update of a policy that targets the cluster's members, so that every member
runs it and only the leader acts. It uses patronictl from the host, or from a
running Docker container: the one given as Docker container, else one named
patroni, else the first whose name or image contains patroni. It reads the
cluster with patronictl list -f json. After the switchover the old leader
shows as stopped for a few seconds before it returns as a replica; the wait
allows for that. Run it once with Dry run on before relying on it: it prints
the cluster as it sees it and the replica it would pick, and changes nothing. It fails, and with it the host's run,
when there is no healthy replica to hand over to, when the switchover is
refused, or when the host is still no replica after the wait. Its parameters
are all optional: dry run, the Docker container, the Patroni configuration
file (found in /etc/patroni/ otherwise), the host's member name (matched by
host name and address otherwise) and the seconds to wait (120). It is not added to any policy for
you; see Scripts for the library. The new leader is reported as
the patroni.leader_changed event, and the alerts the work
causes are held back while the host's maintenance window
is open.
Built-in checks:
- Proxmox subscription. The host reads the status of its own Proxmox
subscription before the dry run and goes on only when it is
activeor there is none (notfound, the no-subscription repository). Otherwise the run is skipped with the reason (for exampleproxmox_subscription: expired) and nothing is installed, becauseaptwould remove packages through the enterprise repository. A host without Proxmox is not affected. - Wait until reachable. A run starts only when the host's agent is connected; it waits until the end of the occurrence and is then skipped (Skipped because the host did not come online in time).
Staging (test hosts patched first, then the rest after the soak time) and Rolling (in a cluster, members one at a time, the node that does not lead first; the next starts when the previous has finished, has come back after a restart and the cluster is healthy again) work as before, within their stage.
Cluster health is what monitoring already knows: every member reports in, and the cluster's own series are good (Patroni running and holding the leader lock, etcd with a leader, Garage healthy, Proxmox quorum, no HA errors and no nodes down). The dashboard reads the current values, not averaged history.
On a Windows host the dry run and the apply are the Windows jobs of the same
names: the apply installs exactly the updates the run chose, by their identity
in Windows Update, and never restarts by itself; a restart follows as the
reboot job when the policy asks for one.
A run that waits more than three days for its turn is dropped; the next occurrence plans it again.
Moving over from older versions
Existing policies are converted when you upgrade. The scope of each becomes a selection (a host or cluster or tag or the whole customer) and the priority follows the old rule (host 30, cluster 20, tag 10, customer 0), so every host stays with the policy that governed it. A window stays the window of its policy. One thing changes: a disabled policy no longer keeps its hosts; they now fall to the next policy that selects them, so check disabled policies that were only there to keep hosts out of patching, and give such hosts an exception instead.
Unattended upgrades
A host where unattended-upgrades or dnf-automatic runs installs
updates on its own, which defeats delays, approvals and windows. The policy
pages warn about such hosts. Selvara does not change that setting on the host.
A host counts as running it only when the configuration is on and the timer
that fires it is enabled (apt-daily-upgrade.timer, or the dnf-automatic
install timer; a dnf-automatic timer that only downloads does not count).
Where the agent cannot read the timer, the configuration decides. The hosts
list and the host's inventory then say what it covers and when it last ran:
| Shown | Meaning |
|---|---|
| Security updates automatic | Only security origins are allowed; other updates stay pending until a patch run installs them. |
| All updates automatic | Regular updates are allowed too (-updates origins, upgrade_type = default). |
| Automatic updates | Switched on, but the allowed origins could not be read. |
The last run comes from the stamp unattended-upgrades leaves under
/var/lib/apt/periodic and is left out when the host has none, as on
dnf-automatic hosts. The Automatic updates filter of the hosts list
selects all of these hosts.
A host's Patches tab
The Patches tab of an agent host's page holds everything about its updates:
- The pending updates with their counts (security and all), and a banner when the host
needs a restart, with a Restart button where you may run the
rebootjob. - Hold and Release for updates.
- Install security updates, Install all, Dry run, and Install selected for the packages ticked in the list.
- A card for the run that is active, with Approve, Reject and Cancel.
- The view History: the host's patch runs and, on Windows, the Windows update history.
The tab is where the patch pages link a host to; the Inventory tab keeps hardware and software only.
Pages
- Overview: how many hosts have security updates outstanding, restarts pending and failed runs, and the latest runs.
- Hosts and Clusters: the patch state of each host and cluster, with
Patch now for a manual run (security, all, or chosen packages; optionally a
dry run only), also in the ⋯ menu of any host row. A host that reports a restart pending also has a Restart
button beside Patch, and the selected hosts can be restarted together. It
appears only where you may run the
rebootjob for the customer, the host is connected and its configuration allows therebootaction. The restart is a job, held back from alerts while the host is down; until it has finished, the row shows the job's state instead of the button. - Pending updates: every update waiting on a host, with its age and the reason it is held (delay, approval, exclusion).
- Approvals: approve per host, per package or all at once. An approval names the candidate version, so it does not carry over to a newer build. Where the customer requires four-eyes approval, a run started by one person is approved by another; elsewhere the person who started a run that waits for removals confirms it themselves. Tick several waiting runs and choose Approve selected, or use Approve all runs, to decide them at once with one reason; runs you may not approve are skipped and counted.
- Deployments: runs in progress and those waiting, with the reason they wait (staging, rolling, unhealthy cluster, host offline).
- Packages: the inventory's package list across the fleet.
- History: every run with initiator, approver, packages, exit code, duration and output.
- Policies: create and change policies.
The lists of hosts, pending updates, approvals and runs have an Operating host filter (all, Linux or Windows), and a host's name is followed by the icon of its operating system or distribution. The filter is in the address like the others. Approve all and Approve for all on the approvals page follow it: with Windows chosen they release only the updates of Windows hosts.
All pages update live.
Permissions
Everything above needs patch.approve for the customer concerned, the
permission the Patcher role carries. Policy changes, manual runs, approvals
and cancellations are written to the audit log.
Alerts and webhooks
Four alert rules about patching exist by default (Alert rules):
| Rule | Metric | Fires when |
|---|---|---|
| Security update outstanding for 35 days | patch_security_age_days | the oldest outstanding security update is older than 35 days |
| Restart pending for 35 days | patch_reboot_pending_days | the host has asked for a restart for more than 35 days |
| Patch run failed | patch_run_failed | the latest finished run of the host failed (looked at for 14 days) |
| Operating system past end of life | os_end_of_life | the host's release is past the vendor's end-of-life date, after which it receives no security updates at all |
A host whose updates could not be read produces no age value, so the three
update rules stay silent for it. os_end_of_life does not depend on the update
list: it comes from the release dates described in
Vulnerability data, and patching cannot clear it, only an
upgrade of the operating system can.
The updates these rules look at are those the mirrors offer now: on apt and
dnf/yum hosts the agent refreshes the package lists itself every 6 hours
(see Inventory).
The webhook event patch.run_finished is sent when a run ends (see
Webhooks); skipped runs, for which nothing was attempted, are not
reported. The data holds the run id, host, policy, state, mode, error, the
number of packages upgraded and removed, whether a restart is required and the
duration.
API
| Request | Permission | Does |
|---|---|---|
POST /api/patches/policies | patch.approve | Creates a policy. |
PATCH, PUT, DELETE /api/patches/policies/{id} | patch.approve | PATCH changes the fields sent, PUT replaces the policy, DELETE deletes it. |
POST /api/patches/runs | patch.approve | Starts manual runs on hosts. |
POST /api/patches/runs/{id}/approve | patch.approve | Approves a run that waits, including one that would remove packages. |
POST /api/patches/runs/{id}/cancel | patch.approve | Cancels a run and its jobs. |
POST, DELETE /api/patches/approvals | patch.approve | Approves or withdraws the approval of updates. |
Troubleshooting
- A host is not offered for patching. Its agent needs
patchinactions, and its inventory must have arrived. - A run is waiting. Its page names the reason: staging soak, an earlier member of the cluster, an unhealthy cluster, a host that has not come back or is not connected, the previous stage or the steps around it, a full batch, a closed window, or an approval.
- A policy does not run at its time. Check that it is enabled, that it has a schedule or a window, that its selection matches hosts in the preview, and that no other policy with a higher priority governs them (the list shows conflicts). Hosts with nothing due, or already busy with another run, get no run.
- A run was skipped with a subscription reason. The host's Proxmox subscription is not active; renew it or set the no-subscription repository up, and the next occurrence goes on.
- A step failed. The step is a script run: its output is on the
script runs page. The account that created the policy needs the
script.runpermission at the customer, and the script's parameters need defaults. - The apply was not sent after the dry run. The dry run would remove packages; approve the run once you have read the list.