Bug 242592 - bectl - cannot destroy a boot environment
Summary: bectl - cannot destroy a boot environment
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-12 08:20 UTC by Slawomir Wojciech Wojtczak
Modified: 2020-01-10 03:40 UTC (History)
5 users (show)

See Also:
kevans: mfc-stable12+
kevans: mfc-stable11+


Attachments
Creation of two BEs (25.29 KB, image/png)
2019-12-13 19:09 UTC, Emrion
no flags Details
This is what I get after reboot (15.52 KB, image/png)
2019-12-13 19:20 UTC, Emrion
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Slawomir Wojciech Wojtczak 2019-12-12 08:20:49 UTC
Hi,

I actually did not had any problems with bectl but there is a thread on FreeBSD Forums that describes quite serious problem with bectl.

The beadm works well here.

This is the summary of the problem:
https://forums.freebsd.org/threads/cannot-destroy-a-boot-environment.73296/#post-447351

Here is the entire thread about the problem:
https://forums.freebsd.org/threads/cannot-destroy-a-boot-environment.73296

Regards.
Comment 1 Emrion 2019-12-13 19:09:24 UTC
Created attachment 209916 [details]
Creation of two BEs

This is an up-to-date FreeBSD 12.1. With bectl I create two BEs, activate the first one and reboot.
Comment 2 Emrion 2019-12-13 19:20:20 UTC
Created attachment 209917 [details]
This is what I get after reboot

I would like to destroy default BE, then rename be1 as default. It's not possible with bectl but no problem with beadm (if I used beadm to create the Bes).
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2019-12-15 20:14:17 UTC
(In reply to Emrion from comment #2)

Yeah, I see what's going on here- we indeed don't currently promote clones of BE snapshots, but we should. It's slightly complicated by the fact that we support deep BEs and need to make sure we handle those, but we'll work out a solution.
Comment 4 Robert Wing freebsd_committer freebsd_triage 2019-12-18 03:06:55 UTC
Hey Kyle,

Have you or anyone else started working on this? 

If not, I can work on a patch for you to review.

-Rob
Comment 5 Kyle Evans freebsd_committer freebsd_triage 2019-12-18 03:26:47 UTC
(In reply to Rob from comment #4)

Hey,

Wes (CC'd now) had started on a patch; I'm not sure what the current status of it is, though. libzfs was being funky funky.
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-01-02 18:47:09 UTC
A commit references this bug:

Author: kevans
Date: Thu Jan  2 18:46:35 UTC 2020
New revision: 356279
URL: https://svnweb.freebsd.org/changeset/base/356279

Log:
  libbe(3): promote dependent clones when destroying an environment

  When removing a boot environment iterate over the dependents and process the
  snapshots by grabbing any clones. Promote the clones we found and then
  remove the target environment.

  This fixes the ability to destroy a boot environment when it has been used
  to spawn one or more other boot environments.

  PR:		242592
  Submitted by:	Wes Maag <jwmaag gmail com> (with changes by myself)
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D22953

Changes:
  head/lib/libbe/be.c
  head/lib/libbe/be.h
  head/lib/libbe/be_error.c
  head/sbin/bectl/tests/bectl_test.sh
Comment 7 Kyle Evans freebsd_committer freebsd_triage 2020-01-02 18:47:49 UTC
Fix committed as r356279; will MFC in ~1 week. Thanks!
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-01-10 03:38:09 UTC
A commit references this bug:

Author: kevans
Date: Fri Jan 10 03:37:54 UTC 2020
New revision: 356593
URL: https://svnweb.freebsd.org/changeset/base/356593

Log:
  MFC r356279: libbe(3): promote dependent clones when destroying a BE

  When removing a boot environment iterate over the dependents and process the
  snapshots by grabbing any clones. Promote the clones we found and then
  remove the target environment.

  This fixes the ability to destroy a boot environment when it has been used
  to spawn one or more other boot environments.

  PR:		242592

Changes:
_U  stable/11/
  stable/11/lib/libbe/be.c
  stable/11/lib/libbe/be.h
  stable/11/lib/libbe/be_error.c
  stable/11/sbin/bectl/tests/bectl_test.sh
_U  stable/12/
  stable/12/lib/libbe/be.c
  stable/12/lib/libbe/be.h
  stable/12/lib/libbe/be_error.c
  stable/12/sbin/bectl/tests/bectl_test.sh