Skip to content

fix: reload systemd after crypttab changes - #688

Open
bataroland wants to merge 2 commits into
linux-system-roles:mainfrom
bataroland:fix/crypttab-systemd-refresh
Open

bataroland wants to merge 2 commits into
linux-system-roles:mainfrom
bataroland:fix/crypttab-systemd-refresh

Conversation

@bataroland

@bataroland bataroland commented Nov 13, 2026 •

Copy link
Copy Markdown

Enhancement:

Make crypttab changes visible to systemd before the storage role returns.

Reason:

Both daemon-reloads currently precede crypttab updates. After creating the first
encrypted volume, its cryptsetup unit can remain absent until a later role run.
That later reload changes the runtime dependency graph even with changed=0.
Crypttab-only changes with no mount entries also need a reload.

Result:

  • Move the existing final reload after crypttab management and register the
    crypttab result. Preserve mount-driven reloads and also reload on a crypttab
    change. Keep native check-mode behavior and the earlier pre-mount reload.
  • Add a first-invocation LUKS2 assertion that reads the generated unit without
    reloading or rerunning the role, plus four Python-2-compatible contract tests.
  • On EL7 (systemd 219), escape the mapper name and add the fixed service
    prefix/suffix instead of passing a template to systemd-escape. The test
    still requires LoadState=loaded and SourcePath=/etc/crypttab.
  • No Python module, public API or handler changes.

Validation:

  • Four new unit cases pass on Python 2.7, 3.9 and 3.10; the original task order
    fails the new ordering/change assertions.
  • Verified on stock CentOS 7 systemd-219-78.el7: the old template invocation
    returned exit code 1; escaping the same mapper name alone succeeded and
    produced the expected service name.
  • On a merge preview against main at f56a4df (including test: mock get_format to fix failing python unit tests #692), all 66 unit
    tests pass on Python 2.7, 3.9 and 3.10.
  • LUKS2 syntax and offline production-profile ansible-lint pass.
  • On disposable blank LVs, the original role fails the new first-invocation
    assertion. Targeted candidate role checks pass creation with and without mount
    entries, check mode on blank volumes, normal/check data/header/mount/unit
    preservation, and removal of stale generated dependencies. Existing volume,
    LUKS-header, mount and cryptsetup-unit snapshots are unchanged after cleanup.
    Tested with Blivet 3.14.2, systemd 259.9 and ansible-core 2.21.5.
  • The complete destructive LUKS2 playbook and supported-platform matrix were not
    run locally. Upstream CI for the current head has not been verified.

Assisted-by: OpenCode using models GPT-6.1 Sol, GPT-6.2 Astra

Signed-off-by: Bata Roland Krisztián batarolandkrisztian@gmail.com

Issue Tracker Tickets (Jira or BZ if any): None.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Pre-merge checks: Passed 2

Check name Status Explanation
Description Format Passed The PR description meets the Description Format check for PR #688 (author bataroland). Checked against the configured criteria and the repository template at .github/pull_request_template.md (which ha…
Ai Agent Attribution Passed The PR body contains the required attribution line: "Assisted-by: OpenCode using models GPT-6.1 Sol, GPT-6.2 Astra". This matches the Assisted-by: <agent> using model(s) <models> format. The PR adds…
Full details: Description Format

Explanation

The PR description meets the Description Format check for PR #688 (author bataroland). Checked against the configured criteria and the repository template at .github/pull_request_template.md (which has Enhancement, Reason, Result, Assisted-by, and Issue Tracker sections): - "Enhancement:" section is present and describes the change (move the final daemon-reload after crypttab management, reload on crypttab changes, EL7 systemd-escape fix). - "Reason:" section is present and explains why: both daemon-reloads precede crypttab updates, so the cryptsetup unit can stay absent until a later run. - "Result:" section is present and states the outcome. - "Signed-off-by:" section is present with the author's name and email (Bata Roland Krisztián <batarolandkrisztian@gmail.com>). - "Issue Tracker Tickets (Jira or BZ if any): None." and "Assisted-by: OpenCode using models ..." are optional sections and are present in the expected form. The PR is titled "fix:" and could also use the bug-fix template (Cause/Consequences/Fix). The check describes that template as optional ("can use"). The author chose the Enhancement structure, which satisfies the base requirements. No explicit failure condition is violated.

Full details: Ai Agent Attribution

Explanation

The PR body contains the required attribution line: "Assisted-by: OpenCode using models GPT-6.1 Sol, GPT-6.2 Astra". This matches the Assisted-by: &lt;agent&gt; using model(s) &lt;models&gt; format. The PR adds AI-assisted code in three files, and each carries an in-line attribution comment in the required format: - tests/unit/test_crypttab_reload.py (new file, line 2): # Assisted by OpenCode using model GPT-6.1 Sol, placed after the SPDX line. - tasks/main-blivet.yml: # Assisted by OpenCode using model GPT-6.1 Sol (added at about line 254). It sits directly above the crypttab lineinfile task. The moved crypttab reload task in the same hunk is adjacent to it. - tests/tests_luks2.yml: # Assisted by OpenCode using models GPT-6.1 Sol, GPT-6.2 Astra (line 110), above the new first-invocation verification block. The git diff main HEAD output also lists unrelated changes (workflow files, tests/unit/test_mount_order.py). These appear to come from base drift and are not part of the attribution assessment. The local main ref is at f56a4df, which is the merge base. No separate unannotated AI-generated file was found. The only residual gap is that the small reload-move hunk in tasks/main-blivet.yml shares a block with the annotated task, not its own comment.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

CI tests do not run automatically on pull requests. A role repository
maintainer can start them by posting a /citest slash command in a
pull request comment.

See GitHub CI testing using /citest
for details.

Run every available CI workflow:

/citest all

Run the linting and other lightweight checks:

/citest linters

Run the integration tests (QEMU/container and Testing Farm):

/citest integration

Run one or more selected workflows by separating their names with spaces:

/citest ansible-lint
/citest ansible-lint markdownlint
Command Check name Description
/citest all All checks listed below Run every CI test available for this role
/citest linters Lint and lightweight checks Run ansible-lint, ansible-test, ansible-managed-var-comment, codespell, markdownlint, pr-title-lint, test_converting_readme, and codeql, python-unit-test, and shellcheck when those workflows exist
/citest integration QEMU/container and Testing Farm checks Run qemu-kvm-integration-tests and tft
/citest ansible-lint Ansible Lint / ansible_lint (<ansible-lint>, <ansible>, <python>) (pull_request) Lint Ansible content after converting the role to collection format
/citest ansible-managed-var-comment Check for ansible_managed variable use in comments / ansible_managed_var_comment (pull_request) Fail if ansible_managed is used in comments
/citest ansible-test Ansible Test / ansible_test (<ansible>, <python>) (pull_request) Run ansible-test sanity tests
/citest codespell Codespell / Check for spelling errors (pull_request) Check for spelling errors
/citest markdownlint Markdown Lint / markdownlint (pull_request) Lint Markdown files
/citest pr-title-lint PR Title Lint / commit-checks Check that the pull request title follows the required format
/citest qemu-kvm-integration-tests Test / scenario (<image>, <env>) (pull_request) Run role integration tests in QEMU VMs and containers
/citest test_converting_readme Test converting README.md to README.html / test_converting_readme (pull_request) Convert README.md to HTML
/citest tft <platform>|ansible-<version> Run integration tests in Testing Farm
/citest woke Woke / Detect non-inclusive language (pull_request) Detect non-inclusive language
/citest codeql CodeQL / Analyze (python) (pull_request) CodeQL security and quality analysis for Python
/citest python-unit-test Python Unit Tests / python (<python>, <os>) (pull_request) Run Python unit tests
/citest shellcheck ShellCheck / shellcheck (pull_request) Lint shell scripts

Post another /citest comment at any time to run another selection.

@richm

richm commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

/citest all

@bataroland bataroland left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running CI. On Fedora 44, Fedora 45 and CentOS Stream 9, tests_luks2.yml passed: immediately after the first role invocation, the new cryptsetup unit had LoadState=loaded and SourcePath=/etc/crypttab, without another reload or role run.

The four new unit tests also passed. The eight Python 3.9 failures are the same get_format failures seen on the unmodified base. Both Fedora QEMU jobs failed during Stratis package removal; the first CentOS 9 QEMU failure was a RAID test where the kernel could not reread the partition table.

I couldn't access the detailed Testing Farm logs. Could you share the first failing task and its error from one of those runs so we can check whether it involves the crypttab reload?

@richm

richm commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

/citest all

bataroland added a commit to bataroland/storage that referenced this pull request Nov 18, 2026
Include linux-system-roles#688 so the role's crypttab entry is visible to systemd before
linux-system-roles#686 inspects the generated unit. Keep the original reload commit in the
history of both branches.

Assisted-by: OpenCode using model GPT-6.2 Astra
Signed-off-by: Bata Roland Krisztián <batarolandkrisztian@gmail.com>
bataroland added a commit to bataroland/storage that referenced this pull request Nov 18, 2026
Include linux-system-roles#688 so the role's crypttab entry is visible to systemd before
linux-system-roles#686 inspects the generated unit. Keep the original reload commit in the
history of both branches.

Assisted-by: OpenCode using model GPT-6.2 Astra
Signed-off-by: Bata Roland Krisztián <batarolandkrisztian@gmail.com>
bataroland added a commit to bataroland/storage that referenced this pull request Nov 19, 2026
Keep the shared first-invocation test in sync with linux-system-roles#688.

Assisted-by: OpenCode using model GPT-6.2 Astra
Signed-off-by: Bata Roland Krisztián <batarolandkrisztian@gmail.com>

@bataroland bataroland left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richm I traced the CentOS 7 test failure to systemd-escape --template: stock systemd 219 rejects systemd-cryptsetup@.service. Fixed in 3ce172d by escaping just the mapper name and using the result as the unit instance. The test still checks LoadState=loaded and SourcePath=/etc/crypttab after the first role invocation, without a manual reload. #686 includes the same commit. Could you rerun CI on 3ce172d?

@spetrosi

Copy link
Copy Markdown
Contributor

/citest all

@bataroland bataroland left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spetrosi, could you run /citest all on 3b11e27? I merged main (25c3070) to pick up #692, #693 and #698. All 66 unit tests passed locally on Python 3.9 with the merged tree.

In the previous full run, the first-run crypttab assertion passed in all seven Testing Farm environments, including CentOS 7. Before any role rerun or manual reload, systemd reported LoadState=loaded and SourcePath=/etc/crypttab. The EL7 LVM pool-member failure tracked in #697 and the Fedora Testing Farm Stratis JSON error also occurred without this PR.

Move the existing final daemon-reload after crypttab management. Preserve mount-driven reloads and the earlier pre-mount reload, and also refresh systemd when crypttab changes without mount entries. Keep native check-mode behavior.

Assert generated-unit availability immediately after the first encrypted-volume creation, before any rerun or manual reload. Add four Python-2-compatible role-contract tests for ordering, change detection and check mode. No module, handler or public API changes.

Assisted-by: OpenCode using model GPT-6.1 Sol
Signed-off-by: Bata Roland Krisztián <batarolandkrisztian@gmail.com>
systemd 219 rejects the cryptsetup template in systemd-escape. Escape
only the mapper name, then use it in the fixed service template. Keep
the first-invocation LoadState and SourcePath assertions intact.

Assisted-by: OpenCode using model GPT-6.2 Astra
Signed-off-by: Bata Roland Krisztián <batarolandkrisztian@gmail.com>
@bataroland
bataroland force-pushed the fix/crypttab-systemd-refresh branch from 3b11e27 to 47ee3fe Compare November 20, 2026 23:30

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants