Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Virtualization:containers
incus
0001-incusd-storage-zfs-Fix-deletion-of-unavail...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-incusd-storage-zfs-Fix-deletion-of-unavailable-pools.patch of Package incus
From 7404e5abf36daf768745bc932d5f4fd0150ec4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@stgraber.org> Date: Fri, 22 Nov 2024 06:50:05 +0000 Subject: [PATCH 1/2] incusd/storage/zfs: Fix deletion of unavailable pools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgraber@stgraber.org> --- internal/server/storage/drivers/driver_zfs.go | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/internal/server/storage/drivers/driver_zfs.go b/internal/server/storage/drivers/driver_zfs.go index da10c39cad7d..54cceb6aa27b 100644 --- a/internal/server/storage/drivers/driver_zfs.go +++ b/internal/server/storage/drivers/driver_zfs.go @@ -407,41 +407,40 @@ func (d *zfs) Delete(op *operations.Operation) error { return err } - if !exists { - return nil - } - - // Confirm that nothing's been left behind - datasets, err := d.getDatasets(d.config["zfs.pool_name"], "all") - if err != nil { - return err - } + if exists { + // Confirm that nothing's been left behind + datasets, err := d.getDatasets(d.config["zfs.pool_name"], "all") + if err != nil { + return err + } - initialDatasets := d.initialDatasets() - for _, dataset := range datasets { - dataset = strings.TrimPrefix(dataset, "/") + initialDatasets := d.initialDatasets() + for _, dataset := range datasets { + dataset = strings.TrimPrefix(dataset, "/") - if slices.Contains(initialDatasets, dataset) { - continue - } + if slices.Contains(initialDatasets, dataset) { + continue + } - fields := strings.Split(dataset, "/") - if len(fields) > 1 { - return fmt.Errorf("ZFS pool has leftover datasets: %s", dataset) + fields := strings.Split(dataset, "/") + if len(fields) > 1 { + return fmt.Errorf("ZFS pool has leftover datasets: %s", dataset) + } } - } - if strings.Contains(d.config["zfs.pool_name"], "/") { - // Delete the dataset. - _, err := subprocess.RunCommand("zfs", "destroy", "-r", d.config["zfs.pool_name"]) - if err != nil { - return err - } - } else { // Delete the pool. - _, err := subprocess.RunCommand("zpool", "destroy", d.config["zfs.pool_name"]) - if err != nil { - return err + if strings.Contains(d.config["zfs.pool_name"], "/") { + // Delete the dataset. + _, err := subprocess.RunCommand("zfs", "destroy", "-r", d.config["zfs.pool_name"]) + if err != nil { + return err + } + } else { + // Delete the pool. + _, err := subprocess.RunCommand("zpool", "destroy", d.config["zfs.pool_name"]) + if err != nil { + return err + } } } -- 2.47.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor