sysroot: Promote the "early prune" behavior to default
authorColin Walters <walters@verbum.org>
Thu, 24 Aug 2023 14:00:13 +0000 (10:00 -0400)
committerColin Walters <walters@verbum.org>
Thu, 31 Aug 2023 14:25:59 +0000 (10:25 -0400)
I think we have enough testing for this, let's default it to
on, and change the variable to allow opt-out in case it does
introduce a regression.

src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-private.h
src/libostree/ostree-sysroot.c
tests/kolainst/destructive/auto-prune.sh

index b756c76a3742a47fec5d69fe6e86609b4af58659..6c2dc1f30f31aeec57aee492fcbd2c39805352b9 100644 (file)
@@ -2843,9 +2843,8 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, GPtrArray *n
   if (!_ostree_sysroot_ensure_writable (self, error))
     return FALSE;
 
-  /* for now, this is gated on an environment variable */
-  const gboolean opted_in = (self->opt_flags & OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE) > 0;
-  if (opted_in && !opts->disable_auto_early_prune
+  const bool skip_early_prune = (self->opt_flags & OSTREE_SYSROOT_GLOBAL_OPT_NO_EARLY_PRUNE) > 0;
+  if (!skip_early_prune && !opts->disable_auto_early_prune
       && !auto_early_prune_old_deployments (self, new_deployments, cancellable, error))
     return FALSE;
 
index a608a7a551d846793d57e55476bad7e7f42629e8..8e6945b293abae3be725b9ad55a17efa0fd85cdf 100644 (file)
@@ -44,7 +44,7 @@ typedef enum
   /* Skip invoking `sync()` */
   OSTREE_SYSROOT_GLOBAL_OPT_SKIP_SYNC = 1 << 0,
   /* See https://github.com/ostreedev/ostree/pull/2847 */
-  OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE = 1 << 1,
+  OSTREE_SYSROOT_GLOBAL_OPT_NO_EARLY_PRUNE = 1 << 1,
   OSTREE_SYSROOT_GLOBAL_OPT_BOOTLOADER_NAMING_2 = 1 << 2,
 } OstreeSysrootGlobalOptFlags;
 
index 36dac18426ef6c27f1bbbda14076ae11746016ae..91b63f945a5d445edd481b676de3c9eec8e319e3 100644 (file)
@@ -179,7 +179,7 @@ ostree_sysroot_init (OstreeSysroot *self)
 {
   const GDebugKey globalopt_keys[] = {
     { "skip-sync", OSTREE_SYSROOT_GLOBAL_OPT_SKIP_SYNC },
-    { "early-prune", OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE },
+    { "no-early-prune", OSTREE_SYSROOT_GLOBAL_OPT_NO_EARLY_PRUNE },
     { "bootloader-naming-2", OSTREE_SYSROOT_GLOBAL_OPT_BOOTLOADER_NAMING_2 },
   };
   const GDebugKey keys[] = {
index 70b71868ddd9821f02beb3026b8904de50b35715..1ec1534e52970cff4e2324aeea8ada11687436bc 100755 (executable)
@@ -44,7 +44,7 @@ assert_bootfs_has_n_bootcsum_dirs 1
 # the booted deployment is never pruned, so this is a hopeless case and auto-pruning can't save us
 consume_bootfs_space
 rpm-ostree rebase :modkernel1
-if OSTREE_SYSROOT_OPTS=early-prune ostree admin finalize-staged |& tee out.txt; then
+if ostree admin finalize-staged |& tee out.txt; then
     assert_not_reached "successfully wrote to filled up bootfs"
 fi
 assert_file_has_content out.txt "Disabling auto-prune optimization; insufficient space left in bootfs"
@@ -58,7 +58,7 @@ rpm-ostree cleanup -bpr
 assert_bootfs_has_n_bootcsum_dirs 1
 
 rpm-ostree rebase :modkernel1
-OSTREE_SYSROOT_OPTS=early-prune ostree admin finalize-staged |& tee out.txt
+ostree admin finalize-staged |& tee out.txt
 assert_not_file_has_content out.txt "updating bootloader in two steps"
 rm out.txt
 
@@ -71,7 +71,7 @@ bootloader_orig=$(sha256sum /boot/loader/entries/*)
 # now try to deploy a third deployment without early pruning; we should hit ENOSPC
 consume_bootfs_space
 rpm-ostree rebase :modkernel2
-if ostree admin finalize-staged |& tee out.txt; then
+if OSTREE_SYSROOT_OPTS=no-early-prune ostree admin finalize-staged |& tee out.txt; then
     assert_not_reached "successfully wrote kernel without auto-pruning"
 fi
 assert_file_has_content out.txt "No space left on device"
@@ -86,7 +86,7 @@ assert_streq "$bootloader_orig" "$(sha256sum /boot/loader/entries/*)"
 
 # now, try again but with auto-pruning enabled
 rpm-ostree rebase :modkernel2
-OSTREE_SYSROOT_OPTS=early-prune ostree admin finalize-staged |& tee out.txt
+ostree admin finalize-staged |& tee out.txt
 assert_file_has_content out.txt "updating bootloader in two steps"
 rm out.txt
 
@@ -120,15 +120,16 @@ unshare -m bash -c \
 consume_bootfs_space "$((free_blocks))"
 
 rpm-ostree rebase :modkernel1
-if ostree admin finalize-staged |& tee out.txt; then
+# Disable auto-pruning to verify we reproduce the bug
+if OSTREE_SYSROOT_OPTS=no-early-prune ostree admin finalize-staged |& tee out.txt; then
     assert_not_reached "successfully wrote kernel without auto-pruning"
 fi
 assert_file_has_content out.txt "No space left on device"
 rm out.txt
 
-# now, try again but with auto-pruning enabled
+# now, try again but with (now default) auto-pruning enabled
 rpm-ostree rebase :modkernel1
-OSTREE_SYSROOT_OPTS=early-prune ostree admin finalize-staged |& tee out.txt
+ostree admin finalize-staged |& tee out.txt
 assert_file_has_content out.txt "updating bootloader in two steps"
 rm out.txt