Skip to content

Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #785

Done

Description

@pithead-developer

What's the problem

rigforge.sh upgrade re-renders units, may rebuild XMRig for minutes, restarts the miner and re-tunes. Inside postinst it holds the dpkg lock and a failure leaves the package half-configured; skipping it leaves rendered units stale; unattended-upgrades could swap a live miner.

What it impacts

Every apt upgrade of an already set-up miner and anyone on unattended-upgrades.

How I found it

Reading upgrade() (2144-2192) and decide_rebuild (1800), and noting rendered units embed absolute lib paths that go stale until upgrade runs. node-manager's postinst (inert first install, version-greater-only, exit 0 on failure with one retry command) is the working precedent.

How important is it

Medium-high: it decides whether apt upgrade is trustworthy on a mining host.

Acceptance criteria

  • On upgrade of a configured host, postinst only writes an upgrade-pending marker under /var/lib/rigforge and starts a one-shot unit with --no-block that runs rigforge upgrade; dpkg returns promptly.
  • The one-shot rebuilds XMRig only when decide_rebuild requires it, re-renders all units, and restarts the miner automatically after success, and only then. On failure the previous build stays active, the marker is kept, the failure shows in status and doctor, and retry is one documented command.
  • postinst never makes dpkg fail because the upgrade failed: it exits 0, the package stays configured, the failure is reported with the single retry command (for example rigforge upgrade), and the previous build keeps running.
  • The upgrade is queued only when the new version is greater than the installed one and a configured miner exists (config present); a first install is inert.
  • First install (no config) never queues an upgrade.
  • A test upgrades from the previous package to the new one on the fake bench and asserts units re-rendered, marker cleared on success, and no restart on failure.
  • Docs show apt-mark hold to defer.

Possible solutions

A oneshot unit started from postinst. A path unit watching the marker is heavier with no benefit. Owner ruled on 2026-11-20: restart automatically, but only after a successful upgrade. node-manager does the activation inside postinst and never fails dpkg on an activation failure; RigForge keeps the one-shot unit outside dpkg because an XMRig rebuild can take minutes, but copies that failure behaviour.

Activity

  1. added this to the v1.20.0 milestone on Nov 20, 2026
  2. added
    enhancement
    infra
    size:M
    on Nov 20, 2026
  3. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #808.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinfrasize:M

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions