Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc finalization #3100

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion man/ostree-admin-deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.

<listitem><para>
The deployment will not be "finalized" by default on shutdown; to later
queue it, use <literal>ostree admin unlock-finalization</literal>.
queue it, use <literal>ostree admin lock-finalization --unlock</literal>.
</para></listitem>
</varlistentry>

Expand Down
3 changes: 2 additions & 1 deletion man/ostree-admin-lock-finalization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
will be set into a "finalization locked" state, which means it will not be queued for the next boot by default.
</para>
<para>
This is the same as the <literal>--lock-finalization</literal> argument for <literal>ostree admin deploy</literal>.
This is the same as the <literal>--lock-finalization</literal> argument for <literal>ostree admin deploy</literal>,
which is the recommended way to use this feature in a race-free way.
</para>
<para>
However more commonly, one will use the <literal>--unlock</literal> argument for this command to later unlock
Expand Down
57 changes: 57 additions & 0 deletions tests/kolainst/destructive/finalization.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -xeuo pipefail

. ${KOLA_EXT_DATA}/libinsttest.sh

require_writable_sysroot
prepare_tmpdir

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# Need to disable gpg verification for test builds
sed -i -e 's,gpg-verify=true,gpg-verify=false,' /etc/ostree/remotes.d/*.conf
# xref https://github.com/coreos/coreos-assembler/pull/2814
systemctl mask --now zincati

# Create a synthetic commit for upgrade
ostree commit --no-bindings --parent="${host_commit}" -b staged-deploy -I --tree=ref="${host_commit}"
newcommit=$(ostree rev-parse staged-deploy)
ostree admin deploy --lock-finalization staged-deploy
systemctl show -p ActiveState ostree-finalize-staged.service | grep active
ostree admin status > status.txt
assert_file_has_content status.txt 'finalization locked'
# Because finalization was locked, we shouldn't deploy on shutdown
/tmp/autopkgtest-reboot "2"
;;
"2")
# Verify we didn't finalize
newcommit=$(ostree rev-parse staged-deploy)
booted=$(rpm-ostree status --json | jq -r .deployments[0].checksum)
jlebon marked this conversation as resolved.
Show resolved Hide resolved
assert_not_streq "${newcommit}" "${booted}"
prev_bootid=$(journalctl --list-boots -o json |jq -r '.[] | select(.index == -1) | .boot_id')
journalctl -b $prev_bootid -u ostree-finalize-staged.service > svc.txt
assert_file_has_content svc.txt 'Not finalizing'
ostree admin status > status.txt
assert_not_file_has_content status.txt 'finalization locked'

# Now re-deploy
ostree admin deploy --lock-finalization staged-deploy
ostree admin status > status.txt
assert_file_has_content status.txt 'finalization locked'
# And unlock
ostree admin lock-finalization --unlock
ostree admin status > status.txt
assert_not_file_has_content status.txt 'finalization locked'

/tmp/autopkgtest-reboot "3"
;;
"3")
newcommit=$(ostree rev-parse staged-deploy)
booted=$(rpm-ostree status --json | jq -r .deployments[0].checksum)
assert_streq "${newcommit}" "${booted}"
prev_bootid=$(journalctl --list-boots -o json |jq -r '.[] | select(.index == -1) | .boot_id')
journalctl -b $prev_bootid -u ostree-finalize-staged.service > svc.txt
assert_file_has_content svc.txt 'Bootloader updated'
;;
*) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;;
esac
Loading