diff options
author | Colin Walters <walters@verbum.org> | 2018-05-03 17:29:06 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-09 20:59:52 +0000 |
commit | 723070bed4fc2eda42f9a35b17cc6192d29901f6 (patch) | |
tree | 735c1677d649f5000cd98d41ea017d991560aa85 | |
parent | 02f3ea9d5ef05b1f26d6691ad1eae73b062c8996 (diff) | |
download | ostree-try.tar.gz |
lib/sysroot: Add OSTREE_EX_STAGE_DEPLOYMENTS environment variabletry
I feel like I'm drowning in a pile of experimental-but-almost-stable
features...
Anyways, since we made the feature opt-in in rpm-ostree in
https://github.com/projectatomic/rpm-ostree/pull/1352
let's mirror that a bit here with an environment variable so people
can play with it more easily.
The tests needed some tweaks; specifically we need to reload the
status fact after making changes. I'm still a bit uncertain
about the Ansible-as-tests.
But we add an upgrade test that uses the new environment variable.
Closes: #1583
Approved by: <try>
-rw-r--r-- | src/libostree/ostree-sysroot-upgrader.c | 44 | ||||
-rw-r--r-- | tests/admin-test.sh | 3 | ||||
-rw-r--r-- | tests/installed/destructive-ansible.yml | 5 | ||||
-rw-r--r-- | tests/installed/destructive/staged-deploy.yml | 25 | ||||
-rw-r--r-- | tests/installed/tasks/install-git.yml | 3 | ||||
-rw-r--r-- | tests/installed/tasks/query-host.yml | 3 |
6 files changed, 56 insertions, 27 deletions
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c index a87548a3..8fb231a3 100644 --- a/src/libostree/ostree-sysroot-upgrader.c +++ b/src/libostree/ostree-sysroot-upgrader.c @@ -644,21 +644,37 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self, GError **error) { g_autoptr(OstreeDeployment) new_deployment = NULL; - if (!ostree_sysroot_deploy_tree (self->sysroot, self->osname, - self->new_revision, - self->origin, - self->merge_deployment, - NULL, - &new_deployment, - cancellable, error)) - return FALSE; - if (!ostree_sysroot_simple_write_deployment (self->sysroot, self->osname, - new_deployment, - self->merge_deployment, - 0, - cancellable, error)) - return FALSE; + /* Experimental flag to enable staging */ + if (getenv ("OSTREE_EX_STAGE_DEPLOYMENTS")) + { + if (!ostree_sysroot_stage_tree (self->sysroot, self->osname, + self->new_revision, + self->origin, + self->merge_deployment, + NULL, + &new_deployment, + cancellable, error)) + return FALSE; + } + else + { + if (!ostree_sysroot_deploy_tree (self->sysroot, self->osname, + self->new_revision, + self->origin, + self->merge_deployment, + NULL, + &new_deployment, + cancellable, error)) + return FALSE; + + if (!ostree_sysroot_simple_write_deployment (self->sysroot, self->osname, + new_deployment, + self->merge_deployment, + 0, + cancellable, error)) + return FALSE; + } return TRUE; } diff --git a/tests/admin-test.sh b/tests/admin-test.sh index dd87cd11..d23e677d 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -78,7 +78,8 @@ assert_ostree_deployment_refs 1/1/0 ${CMD_PREFIX} ostree admin status echo "ok layout" -if ${CMD_PREFIX} ostree admin deploy --stage --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then +assert_file_has_content_literal err.txt "Cannot stage a deployment when not currently booted into an OSTree system" +if env OSTREE_EX_STAGE_DEPLOYMENTS=1 ${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then fatal "staged when not booted" fi assert_file_has_content_literal err.txt "Cannot stage a deployment when not currently booted into an OSTree system" diff --git a/tests/installed/destructive-ansible.yml b/tests/installed/destructive-ansible.yml index a0e69aa1..c72f6b82 100644 --- a/tests/installed/destructive-ansible.yml +++ b/tests/installed/destructive-ansible.yml @@ -9,10 +9,7 @@ tests: "." tasks: - import_tasks: tasks/disable-all-rpmmd-repos.yml - - import_tasks: tasks/query-host.yml - - set_fact: - rpmostree_initial_deployment: "{{ rpmostree_status[\"deployments\"][0] }}" - import_tasks: tasks/install-git.yml when: use_git_build - + - import_tasks: tasks/query-host.yml - import_tasks: destructive/staged-deploy.yml diff --git a/tests/installed/destructive/staged-deploy.yml b/tests/installed/destructive/staged-deploy.yml index 723dbf55..f34550a2 100644 --- a/tests/installed/destructive/staged-deploy.yml +++ b/tests/installed/destructive/staged-deploy.yml @@ -27,16 +27,31 @@ - name: Check that deploy-staged service worked shell: | set -xeuo pipefail + rpm-ostree status # Assert that the previous boot had a journal entry for it journalctl -b "-1" -u ostree-finalize-staged.service | grep -q -e 'Transaction complete' # 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: | + +- name: Upgrade with staging + shell: | set -xeuo pipefail + test '!' -f /run/ostree/staged-deployment + ostree admin deploy --stage staged-deploy + test -f /run/ostree/staged-deployment + origcommit=$(ostree rev-parse staged-deploy) + cd /ostree/repo/tmp + ostree checkout -H "${origcommit}" t + ostree commit --no-bindings --parent="${origcommit}" -b staged-deploy -I --consume t + newcommit=$(ostree rev-parse staged-deploy) + env OSTREE_EX_STAGE_DEPLOYMENTS=1 ostree admin upgrade >out.txt + test -f /run/ostree/staged-deployment + # Debating bouncing back out to Ansible for this + firstdeploycommit=$(rpm-ostree status |grep 'Commit:' |head -1|sed -e 's,^ *Commit: *,,') + test "${firstdeploycommit}" = "${newcommit}" + # Cleanup rpm-ostree cleanup -rp +- import_tasks: ../tasks/query-host.yml # Ensure we can unstage - name: Write staged-deploy commit, then unstage @@ -50,8 +65,6 @@ ostree admin status > status.txt grep -vqFe '(staged)' status.txt test '!' -f /run/ostree/staged-deployment - environment: - commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}" - name: Staged should be overwritten by non-staged shell: | diff --git a/tests/installed/tasks/install-git.yml b/tests/installed/tasks/install-git.yml index 33fe385e..8216afeb 100644 --- a/tests/installed/tasks/install-git.yml +++ b/tests/installed/tasks/install-git.yml @@ -8,7 +8,8 @@ synchronize: src=build/x86_64/ dest=/root/x86_64/ archive=yes - name: Install RPMs shell: rpm-ostree override replace /root/x86_64/*.rpm -- include_tasks: ../tasks/reboot.yml +- import_tasks: ../tasks/reboot.yml +- import_tasks: ../tasks/query-host.yml - command: ostree --version register: ostree_new_version - set_fact: diff --git a/tests/installed/tasks/query-host.yml b/tests/installed/tasks/query-host.yml index 2a67dbdf..d572ae64 100644 --- a/tests/installed/tasks/query-host.yml +++ b/tests/installed/tasks/query-host.yml @@ -1,4 +1,5 @@ -- command: rpm-ostree status --json +- name: Load status json + command: rpm-ostree status --json changed_when: False register: rpmostree_status_json - set_fact: |