lib/sysroot: Add OSTREE_EX_STAGE_DEPLOYMENTS environment variable
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: jlebon
This commit is contained in:
parent
605d313206
commit
6873650cae
|
|
@ -644,6 +644,21 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(OstreeDeployment) new_deployment = NULL;
|
g_autoptr(OstreeDeployment) new_deployment = NULL;
|
||||||
|
|
||||||
|
/* 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,
|
if (!ostree_sysroot_deploy_tree (self->sysroot, self->osname,
|
||||||
self->new_revision,
|
self->new_revision,
|
||||||
self->origin,
|
self->origin,
|
||||||
|
|
@ -659,6 +674,7 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self,
|
||||||
0,
|
0,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo "1..$((24 + ${extra_admin_tests:-0}))"
|
echo "1..$((25 + ${extra_admin_tests:-0}))"
|
||||||
|
|
||||||
function validate_bootloader() {
|
function validate_bootloader() {
|
||||||
cd ${test_tmpdir};
|
cd ${test_tmpdir};
|
||||||
|
|
@ -215,6 +215,11 @@ validate_bootloader
|
||||||
echo "ok upgrade bare"
|
echo "ok upgrade bare"
|
||||||
|
|
||||||
os_repository_new_commit
|
os_repository_new_commit
|
||||||
|
if env OSTREE_EX_STAGE_DEPLOYMENTS=1 ${CMD_PREFIX} ostree admin upgrade --os=testos 2>err.txt; then
|
||||||
|
fatal "staged when not booted"
|
||||||
|
fi
|
||||||
|
echo "ok upgrade failed when staged"
|
||||||
|
|
||||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||||
${CMD_PREFIX} ostree admin upgrade --os=testos
|
${CMD_PREFIX} ostree admin upgrade --os=testos
|
||||||
origrev=${rev}
|
origrev=${rev}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,7 @@
|
||||||
tests: "."
|
tests: "."
|
||||||
tasks:
|
tasks:
|
||||||
- import_tasks: tasks/disable-all-rpmmd-repos.yml
|
- 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
|
- import_tasks: tasks/install-git.yml
|
||||||
when: use_git_build
|
when: use_git_build
|
||||||
|
- import_tasks: tasks/query-host.yml
|
||||||
- import_tasks: destructive/staged-deploy.yml
|
- import_tasks: destructive/staged-deploy.yml
|
||||||
|
|
|
||||||
|
|
@ -27,16 +27,31 @@
|
||||||
- name: Check that deploy-staged service worked
|
- name: Check that deploy-staged service worked
|
||||||
shell: |
|
shell: |
|
||||||
set -xeuo pipefail
|
set -xeuo pipefail
|
||||||
|
rpm-ostree status
|
||||||
# Assert that the previous boot had a journal entry for it
|
# Assert that the previous boot had a journal entry for it
|
||||||
journalctl -b "-1" -u ostree-finalize-staged.service | grep -q -e 'Transaction complete'
|
journalctl -b "-1" -u ostree-finalize-staged.service | grep -q -e 'Transaction complete'
|
||||||
# And there should not be a staged deployment
|
# And there should not be a staged deployment
|
||||||
test '!' -f /run/ostree/staged-deployment
|
test '!' -f /run/ostree/staged-deployment
|
||||||
- name: Rollback
|
|
||||||
shell: rpm-ostree rollback
|
- name: Upgrade with staging
|
||||||
- include_tasks: ../tasks/reboot.yml
|
shell: |
|
||||||
- shell: |
|
|
||||||
set -xeuo pipefail
|
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
|
rpm-ostree cleanup -rp
|
||||||
|
- import_tasks: ../tasks/query-host.yml
|
||||||
|
|
||||||
# Ensure we can unstage
|
# Ensure we can unstage
|
||||||
- name: Write staged-deploy commit, then unstage
|
- name: Write staged-deploy commit, then unstage
|
||||||
|
|
@ -50,8 +65,6 @@
|
||||||
ostree admin status > status.txt
|
ostree admin status > status.txt
|
||||||
grep -vqFe '(staged)' status.txt
|
grep -vqFe '(staged)' status.txt
|
||||||
test '!' -f /run/ostree/staged-deployment
|
test '!' -f /run/ostree/staged-deployment
|
||||||
environment:
|
|
||||||
commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
|
|
||||||
|
|
||||||
- name: Staged should be overwritten by non-staged
|
- name: Staged should be overwritten by non-staged
|
||||||
shell: |
|
shell: |
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
synchronize: src=build/x86_64/ dest=/root/x86_64/ archive=yes
|
synchronize: src=build/x86_64/ dest=/root/x86_64/ archive=yes
|
||||||
- name: Install RPMs
|
- name: Install RPMs
|
||||||
shell: rpm-ostree override replace /root/x86_64/*.rpm
|
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
|
- command: ostree --version
|
||||||
register: ostree_new_version
|
register: ostree_new_version
|
||||||
- set_fact:
|
- set_fact:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
- command: rpm-ostree status --json
|
- name: Load status json
|
||||||
|
command: rpm-ostree status --json
|
||||||
changed_when: False
|
changed_when: False
|
||||||
register: rpmostree_status_json
|
register: rpmostree_status_json
|
||||||
- set_fact:
|
- set_fact:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue