Skip to content

feat(packer): bake the rescue and check units - #114

Merged
retr0h merged 6 commits into
mainfrom
feat/rescue-boot-unit
Dec 6, 2026
Merged

retr0h merged 6 commits into
mainfrom
feat/rescue-boot-unit

Conversation

@retr0h

@retr0h retr0h commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Specs: osapi-io/specs#750 and osapi-io/specs#757

The lab image bakes the three units that osapi agent service install writes for pending changes (osapi-io/osapi#1707), as it bakes the unit of the agent:

  • packer/osapi-rescue-boot.service: a oneshot before osapi-agent.service that runs osapi agent rescue --all, so a reboot rolls back each pending change. The packer build installs it and enables it.
  • packer/osapi-rescue@.service: the template unit of each pending change (osapi-rescue@<job>). It is Type=notify: it reports ready only after it loads the job, and a stop from a confirm exits 0.
  • packer/osapi-netplan-check@.service: a oneshot template that runs osapi agent rescue --check --job %i, so the validation of a netplan change runs as root.

osapi starts the two templates by name. The lab agent runs as root, so the lab has no sudoers lines for them. A VM that upgrades in place, such as debian-lts, is never baked again, so the lab_agent role installs the same three files on each VM it runs on (owner root, mode 0644, a daemon reload when one changed, and the boot unit enabled). Thus a bump and a deploy both give them to an in-place VM.

This needs just deploy, which bakes new images, because packer/ changed. just bump refuses to run until then.

Checks: just test passes (ansible-lint, packer fmt, md format). The lab run of osapi#1707 deploys these images and runs the integration tests on ubuntu-1, debian-1 and debian-lts.

🤖 Generated with Claude Code

Each VM gets osapi-rescue-boot.service, as osapi agent service install
writes it, so a reboot rolls back each pending change of osapi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h retr0h added needs-standards-review The author asks for the independent standards review needs-code-review The author asks for the independent code review labels Dec 4, 2026
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards review: changes requested (head 52f7c12).

  1. The header of the role now disagrees with the role. ansible/roles/lab_agent/tasks/main.yml:1-4 says that the role is a new linux build and a restart, and that "each other change replaces the VM with a clone of its image". The new tasks install and enable a systemd unit on a running VM. The agent's own unit is in the image (packer/osapi-agent.service, installed in packer/lab.pkr.hcl:220-227). Put osapi-rescue-boot.service in packer/ next to it, so that just deploy bakes it. If the owner wants it on running VMs before the next deploy, keep the tasks and change the header of the role to say so.
  2. A second copy of the unit. The unit text is a hand copy of what initsys.SystemdOneshot writes in osapi#1707. The comment says "as osapi agent service install writes it", but nothing checks it. If the unit stays in the lab, write in the comment the osapi file that is its source, so a change there finds this copy.

Checked with no finding: commit subject (45 characters), Specs: link to specs#750 and its link back, ansible module names, the linux-only scope of the role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h retr0h changed the title feat(lab_agent): install the boot rescue unit feat(packer): bake the boot rescue unit into the image Dec 5, 2026
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 2e75bc8: the unit is in the image (packer/osapi-rescue-boot.service, with a comment that names the osapi files it copies; installed and enabled in the packer build), and the role tasks are gone. The PR body says it needs just deploy. No doc of the lab lists the units of the image, so no doc changed. just test passes; no lab recipe ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Added in f97dced: the template packer/osapi-rescue@.service is in the image. The lab agent runs as root, so the lab has no sudoers lines for it. just test passes; no lab recipe ran. The PR still needs just deploy.

@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards review: approved (head f97dced).

Both findings of the last review are fixed: the units are in the image (packer/osapi-rescue-boot.service, packer/osapi-rescue@.service, installed and enabled in packer/lab.pkr.hcl), the lab_agent role is back to a build and a restart, and each unit names its source in osapi (SystemdOneshot, SystemdInstance, rescueService, rescueUnit). The units agree with the ones that osapi#1707 writes at 4104e5d8. The template has no [Install], and the boot unit is enabled. Root agent, so no sudoers lines in the lab: correct.

One item outside this PR: its specs PR, osapi-io/specs#750, still says that lab_agent installs osapi-rescue-boot.service, and does not name the template. I wrote that on specs#750.

@retr0h retr0h added standards-reviewed An independent reviewer checked this PR against the standards and removed needs-standards-review The author asks for the independent standards review labels Dec 5, 2026
Same as the template that osapi agent service install writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Added Restart=on-failure to packer/osapi-rescue@.service, as in the osapi template: f279783. No recipe was run.

@retr0h retr0h added code-reviewed An independent reviewer checked correctness, bugs and edge cases and removed needs-code-review The author asks for the independent code review labels Dec 5, 2026
Same templates as osapi agent service install writes: the rescue
unit is Type=notify, and the check of a new config is a oneshot unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards re-review at ea050bb. Changes requested.

The new packer/osapi-netplan-check@.service has the same lines as the template that checkUnit of osapi#1707 writes (ExecStart ... agent rescue --check --job %i, Type=oneshot). The rescue template is now Type=notify with Restart=on-failure, as osapi writes it. The packer build installs the check template.

Open items:

  1. The squash subject is too long. The PR has five commits, and the repository squashes with the PR title. The title, "feat(packer): bake the boot rescue unit into the image", has 54 characters. The rule is 50 or fewer. The new commit ea050bbb also has 53. A title such as "feat(packer): bake the rescue and check units" has 45.
  2. The description is stale. It names the boot unit and the rescue template only. It does not name the check template, or the change of the rescue template to Type=notify.
  3. The specs PR disagrees. specs#750 says that the image bakes "two more units". It bakes three now. I put specs#750 back to needs-standards-review.

The label is needs-standards-review.

@retr0h retr0h added needs-standards-review The author asks for the independent standards review and removed standards-reviewed An independent reviewer checked this PR against the standards labels Dec 5, 2026
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Code review: approved (head ea050bb), already labeled. The change is the check template and Type=notify on the rescue template. Both match what osapi agent service install writes at osapi #1707 d65b1fa6d5: the rescue unit has Type=notify, ExecStart=... agent rescue --wait --job %i and Restart=on-failure, and the check unit has Type=oneshot with agent rescue --check --job %i. The packer file provisioner and the install line for the new template are in place. Order of the lines in [Service] differs from osapi's output and does not matter to systemd.

@retr0h retr0h changed the title feat(packer): bake the boot rescue unit into the image feat(packer): bake the rescue and check units Dec 5, 2026
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Fixed both standards items: the title is now 45 characters (the squash commit takes it), and the description names the check template and Type=notify.

@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards re-check at ea050bb. Approved.

Both items are fixed. The title, which becomes the squash subject, has 45 characters. The description names the three units, Type=notify and the check template, and matches the four files of the diff. The PR changes no lab_agent file, as the description says.

specs#750 still says "two more units". That item is on specs#750, not on this PR.

@retr0h retr0h added standards-reviewed An independent reviewer checked this PR against the standards and removed needs-standards-review The author asks for the independent standards review labels Dec 5, 2026
A VM that upgrades in place is never baked again, so it never got the
units of packer/. lab_agent installs the three from the same files, so a
bump and a deploy reach it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Code review: approved (head 83d795a), delta from ea050bb only. The three files (osapi-rescue-boot.service, osapi-rescue@.service, osapi-netplan-check@.service) exist in packer/; lab_root is set in group_vars/all.yml; the role runs only for the Linux VMs (it copies the linux build). The copy sets owner root and mode 0644, reports changed only when a file differs, and the enable task reloads systemd only then, so a VM that the image already baked sees no change. The units run no matter what lab_agent_update says, so a restart-only run also installs them, and the agent needs no restart for them, since the unit starts read the files after the reload. I ran no playbook.

@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards re-review at 83d795a. Changes requested: one item.

The new tasks meet the rules:

  • lab_agent copies the three units from packer/, so the image and the role have one source.
  • The units are owner root and mode 0644. systemd reloads only when a file changed, and the boot unit is enabled.
  • lab_root is defined in the vars of the role.
  • The description now tells why: a VM that upgrades in place is never baked again.
  • The commit 83d795a7 has 49 characters and its trailer. The title has 45.

Open: the description has Specs: https://github.com/osapi-io/specs/pull/750, which merged before this change. The page change for the lab_agent task is specs#757. Name it in the Specs: line too.

I moved the label back to needs-standards-review.

@retr0h retr0h added needs-standards-review The author asks for the independent standards review and removed standards-reviewed An independent reviewer checked this PR against the standards labels Dec 5, 2026
@retr0h

retr0h commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Standards re-check at 83d795a. Approved.

The Specs: line now names specs#750 and specs#757.

@retr0h retr0h added standards-reviewed An independent reviewer checked this PR against the standards and removed needs-standards-review The author asks for the independent standards review labels Dec 5, 2026
@retr0h
retr0h merged commit 24824d2 into main Dec 6, 2026
5 checks passed
@retr0h
retr0h deleted the feat/rescue-boot-unit branch December 6, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviewed An independent reviewer checked correctness, bugs and edge cases standards-reviewed An independent reviewer checked this PR against the standards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant