deploy: Remove lock when re-staging
authorColin Walters <walters@verbum.org>
Fri, 13 Oct 2023 17:45:04 +0000 (13:45 -0400)
committerColin Walters <walters@verbum.org>
Fri, 13 Oct 2023 17:45:04 +0000 (13:45 -0400)
This closes the biggest foot-gun when doing e.g.
`rpm-ostree rebase` when zincati is running on a FCOS system.

Previously if zincati happened to have staged + locked a deployment,
we'd keep around the lock which is definitely not what is desired.

src/libostree/ostree-sysroot-deploy.c
tests/kolainst/destructive/staged-deploy.sh

index e7b91b697a6d2a6cda93c676f61c6b991b230bc0..6cdef14526c2b405a1ddc72034fb2270eb80fb26 100644 (file)
@@ -3676,6 +3676,9 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, const char *osname,
     {
       if (!_ostree_sysroot_rmrf_deployment (self, self->staged_deployment, cancellable, error))
         return FALSE;
+      // Also remove the lock; xref https://github.com/ostreedev/ostree/issues/3025
+      if (!ot_ensure_unlinked_at (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED, error))
+        return FALSE;
     }
 
   /* Bump mtime so external processes know something changed, and then reload. */
index c923605f5fc6c1a90ef4c200396b312b8311d3de..01c2b48916a45afe070159a8b523a69c843d1f64 100755 (executable)
@@ -91,6 +91,14 @@ EOF
     test ! -f /run/ostree/staged-deployment-locked
     echo "ok cleanup staged"
 
+    # And verify that re-staging cleans the previous lock
+    test '!' -f /run/ostree/staged-deployment
+    ostree admin deploy --stage staged-deploy
+    test -f /run/ostree/staged-deployment
+    test '!' -f /run/ostree/staged-deployment-locked
+    ostree admin undeploy 0
+    echo "ok restage unlocked"
+
     # Upgrade with staging
     ostree admin deploy --stage staged-deploy
     origcommit=$(ostree rev-parse staged-deploy)