lib/sysroot: Move staged into deployment list, rework handling

Followup to: https://github.com/ostreedev/ostree/pull/1503
After starting some more work on on this in rpm-ostree, it is
actually simpler if the staged deployment just shows up in the list.

It's effectively opt-in today; down the line we may make it the default,
but I worry about breaking things that e.g. assume they can mutate
the deployment before rebooting and have `/etc` already merged.

There's not that many things in libostree that iterate over the deployment
list.  The biggest change here is around the
`ostree_sysroot_write_deployments_with_options` API.  I initially
tried hard to support a use case like "push a rollback" while retaining
the staged deployment, but everything gets very messy because that
function truly is operating on the bootloader list.

For now what I settled on is to just discard the staged deployment;
down the line we can enhance things.

Where we then have some new gymnastics is around implementing
the finalization; we need to go to some effort to pull the staged
deployment out of the list and mark it as unstaged, and then pass
it down to `write_deployments()`.

Closes: #1539
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2018-04-18 18:59:15 +00:00
1 parent 09dc2a8772
commit 16d3359bf8
5 files changed
+113 -32

No files matched your search

+36 -2
View File
@@ -1,9 +1,11 @@
# Test the deploy --stage functionality
# Test the deploy --stage functionality; first, we stage a deployment
# reboot, and validate that it worked.
- name: Write staged-deploy commit
shell: |
ostree --repo=/ostree/repo commit --parent="${commit}" -b staged-deploy --tree=ref="${commit}" --no-bindings
ostree admin deploy --stage --karg-proc-cmdline --karg=ostreetest=yes staged-deploy
test -f /run/ostree/staged-deployment
environment:
commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
- include_tasks: ../tasks/reboot.yml
@@ -13,12 +15,44 @@
journalctl -b "-1" -u ostree-finalize-staged.service | grep -q -e 'Transaction complete'
# And that we have the new kernel argument
grep -q -e 'ostreetest=yes' /proc/cmdline
# And there should not be a staged deployment
test '!' -f /run/ostree/staged-deployment
- name: Rollback
shell: rpm-ostree rollback
- include_tasks: ../tasks/reboot.yml
- shell: |
ostree refs --delete staged-deploy
rpm-ostree cleanup -rp
# And now we shouldn't have the kernel commandline entry
- name: Check we do not have new kernel cmdline entry
shell: grep -qv -e 'ostreetest=yes' /proc/cmdline
# Ensure we can unstage
- name: Write staged-deploy commit, then unstage
shell: |
ostree admin deploy --stage --karg-proc-cmdline --karg=ostreetest=yes staged-deploy
ostree admin status > status.txt
grep -qFe '(staged)' status.txt
test -f /run/ostree/staged-deployment
ostree admin undeploy 0
ostree admin status > status.txt
grep -vqFe '(staged)' status.txt
test '!' -f /run/ostree/staged-deployment
environment:
commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
# Staged should be overwritten by non-staged
- name: Write staged-deploy commit, then unstage
shell: |
ostree admin deploy --stage --karg-proc-cmdline --karg=ostreetest=yes staged-deploy
test -f /run/ostree/staged-deployment
ostree --repo=/ostree/repo commit --parent="${commit}" -b nonstaged-deploy --tree=ref="${commit}" --no-bindings
ostree admin deploy --karg-proc-cmdline --karg=ostreetest=yes nonstaged-deploy
ostree admin status > status.txt
grep -vqFe '(staged)' status.txt
test '!' -f /run/ostree/staged-deployment
ostree admin undeploy 0
environment:
commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
- name: Cleanup refs
shell: ostree refs --delete staged-deploy nonstaged-deploy