aboutsummaryrefslogtreecommitdiff
path: root/sbin/bectl
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2023-07-11 05:43:51 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-07-11 05:44:13 +0000
commit5d0826017fc9b84f50ef19b0d452bc0590072f2d (patch)
treebb1bad4737e44bb740fff326a37eb4893af703bf /sbin/bectl
parent43ed91e00bbb1c7edadbe1c210d8e57d66a3badd (diff)
downloadsrc-5d0826017fc9b84f50ef19b0d452bc0590072f2d.tar.gz
src-5d0826017fc9b84f50ef19b0d452bc0590072f2d.zip
libbe: promote activated BEs all the way
This matches the beadm behavior; generally, we need to keep promoting until the BE is no longer a clone from a snapshot. This fixes scenarios where the dataset associated with a BE's origin is itself a clone, activating the BE previously would promote it to a clone of the origin's origin. We could keep using be_get_dataset_props here, except for two annoyances: 1.) I couldn't find a clean way to just clear an nvlist rather than having to re-alloc it, and I didn't want to just remove the one prop we're inspecting out of it. 2.) That's a lot of overhead when all we want to do is fetch the origin anyways. Note that this is not a complete fix, but it does fix the majority of cases; deep BE subordinates are still notably broken, pending a patch from Christian. Reported by: R. Christian McDonald <rcm@rcm.sh> Reviewed by: rew Differential Revision: https://reviews.freebsd.org/D40903
Diffstat (limited to 'sbin/bectl')
-rwxr-xr-xsbin/bectl/tests/bectl_test.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh
index 5f865b86954e..7ca7af8a1abf 100755
--- a/sbin/bectl/tests/bectl_test.sh
+++ b/sbin/bectl/tests/bectl_test.sh
@@ -525,6 +525,61 @@ bectl_jail_cleanup()
bectl_cleanup ${zpool}
}
+atf_test_case bectl_promotion cleanup
+bectl_promotion_head()
+{
+
+ atf_set "descr" "Check bectl promotion upon activation"
+ atf_set "require.user" root
+}
+bectl_promotion_body()
+{
+ if [ "$(atf_config_get ci false)" = "true" ] && \
+ [ "$(uname -p)" = "i386" ]; then
+ atf_skip "https://bugs.freebsd.org/249055"
+ fi
+
+ if [ "$(atf_config_get ci false)" = "true" ] && \
+ [ "$(uname -p)" = "armv7" ]; then
+ atf_skip "https://bugs.freebsd.org/249229"
+ fi
+
+ cwd=$(realpath .)
+ zpool=$(make_zpool_name)
+ disk=${cwd}/disk.img
+ mount=${cwd}/mnt
+ root=${mount}/root
+
+ bectl_create_setup ${zpool} ${disk} ${mount}
+ atf_check mkdir -p ${root}
+
+ # Sleeps interspersed to workaround some naming quirks; notably,
+ # bectl will append a serial if two snapshots were created within
+ # the same second, but it can only do that for the one root it's
+ # operating on. It won't check that other roots don't have a snapshot
+ # with the same name, and the promotion will fail.
+ atf_check bectl -r ${zpool}/ROOT rename default A
+ sleep 1
+ atf_check bectl -r ${zpool}/ROOT create -e A B
+ sleep 1
+ atf_check bectl -r ${zpool}/ROOT create -e B C
+
+ # C should be a clone of B to start with
+ atf_check -o not-inline:"-" zfs list -H -o origin ${zpool}/ROOT/C
+
+ # Activating it should then promote it all the way out of clone-hood.
+ # This entails two promotes internally, as the first would promote it to
+ # a snapshot of A before finally promoting it the second time out of
+ # clone status.
+ atf_check -o not-empty bectl -r ${zpool}/ROOT activate C
+ atf_check -o inline:"-\n" zfs list -H -o origin ${zpool}/ROOT/C
+}
+bectl_promotion_cleanup()
+{
+
+ bectl_cleanup $(get_zpool_name)
+}
+
atf_init_test_cases()
{
atf_add_test_case bectl_create
@@ -534,4 +589,5 @@ atf_init_test_cases()
atf_add_test_case bectl_mount
atf_add_test_case bectl_rename
atf_add_test_case bectl_jail
+ atf_add_test_case bectl_promotion
}