Skip to content

Commit

Permalink
Unmount filesystem before dropping to fail early if filesystem is busy (
Browse files Browse the repository at this point in the history
  • Loading branch information
outofforest committed Aug 24, 2022
1 parent c2200dc commit 695eb48
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions infra/storage/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ func (d *zfsDriver) Drop(ctx context.Context, buildID types.BuildID) error {
if err != nil {
return errors.WithStack(fmt.Errorf("build %s does not exist: %w", buildID, types.ErrImageDoesNotExist))
}
mounted, _, err := filesystem.GetProperty(ctx, "mounted")
if err != nil {
return err
}
if mounted == "yes" {
if err := filesystem.Unmount(ctx); err != nil {
return err
}
}

if err := filesystem.Destroy(ctx, zfs.DestroyRecursive); err != nil {
return errors.WithStack(fmt.Errorf("build %s have children: %w", buildID, ErrImageHasChildren))
Expand Down

0 comments on commit 695eb48

Please sign in to comment.