Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete dataset (v0.4.0) #44

Open
Tualua opened this issue Oct 14, 2022 · 4 comments
Open

Cannot delete dataset (v0.4.0) #44

Tualua opened this issue Oct 14, 2022 · 4 comments

Comments

@Tualua
Copy link

Tualua commented Oct 14, 2022

Hello! I cannot delete dataset, both ds.Destroy and ds.DestroyRecursive returns "dataset is busy", however I can delete it with "zfs destroy"

zfs-2.1.0

What am I missing?

@fkasumovic
Copy link
Contributor

@Tualua
Hmm, on first thought, no idea it could be anything.
Can you send me a minimal code that will reproduce the issue?

@Tualua
Copy link
Author

Tualua commented Nov 14, 2022

Sorry for late reply

Example code:

func ZfsDestroyDataset(dataset string) (err error) {
	var (
		ds zfs.Dataset
	)
	if ds, err = zfs.DatasetOpenSingle(dataset); err != nil {
		err = fmt.Errorf("cannot open dataset: %s", err.Error())
	} else {
		defer ds.Close()
		if err = ds.Destroy(false); err != nil {
			err = fmt.Errorf("cannot delete dataset: %s", err.Error())
		}
	}
	return err
}

@alphandbelt
Copy link

Hello! I cannot delete dataset, both ds.Destroy and ds.DestroyRecursive returns "dataset is busy", however I can delete it with "zfs destroy"

zfs-2.1.0

What am I missing?

In my previous testing scenario, there is an issue when trying to delete a pool created via the command line using the API interface. However, when a pool is created using the API interface and then deleted using the same API interface, there is no problem.

@fkasumovic
Copy link
Contributor

@alphandbelt Is dataset mounted? Because 'zfs destroy' will unmount or try to unmount implicitly, thats not the case with an API.

https://openzfs.github.io/openzfs-docs/man/master/8/zfs-destroy.8.html
"Destroys the given dataset. By default, the command unshares any file systems that are currently shared, unmounts any file systems that are currently mounted, and refuses to destroy a dataset that has active dependents (children or clones)."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants