Skip to content

Commit

Permalink
daemon: Retain pinned deployments
Browse files Browse the repository at this point in the history
Followup to: ostreedev/ostree#1464

Ideally, we'd delegate more logic around these things to libostree, but we're
not there yet.

This means e.g. `rpm-ostree cleanup -r` for a pinned rollback will just silently
skip it.  It'd be nicer to emit an error probably, but that'd be quite a bit
more work.

Closes: #1293

Closes: #1309
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Mar 23, 2018
1 parent 4291500 commit 9ddf65a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/daemon/rpmostree-sysroot-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,10 @@ rpmostree_syscore_filter_deployments (OstreeSysroot *sysroot,
continue;
}

/* Is this deployment for a different osname? Keep it. */
if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
const gboolean osname_matches =
strcmp (ostree_deployment_get_osname (deployment), osname) == 0;
/* Retain deployments for other osnames, as well as pinned ones */
if (!osname_matches || ostree_deployment_is_pinned (deployment))
{
g_ptr_array_add (new_deployments, g_object_ref (deployment));
continue;
Expand Down
10 changes: 10 additions & 0 deletions tests/vmcheck/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ vm_rpmostree status > status.txt
assert_not_file_has_content status.txt "Pinned: yes"
echo "ok pinning"

vm_cmd ostree admin pin 0
vm_rpmostree reload # Try to avoid reload races
vm_rpmostree cleanup -p
vm_assert_status_jq ".deployments|length == 2"
vm_cmd ostree admin pin -u 0
vm_rpmostree reload # Try to avoid reload races
vm_rpmostree cleanup -p
vm_assert_status_jq ".deployments|length == 1"
echo "ok pinned retained"

# https://github.com/ostreedev/ostree/pull/1055
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck --timestamp=\"October 25 1985\"
if vm_rpmostree upgrade 2>err.txt; then
Expand Down

0 comments on commit 9ddf65a

Please sign in to comment.