Skip to content

Commit

Permalink
don't fail on deletion of qgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed May 25, 2024
1 parent bdd3fc3 commit 047ff56
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/storage/filesystem/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ func (p *btrfsPool) removeVolume(root string) error {

qgroupID := fmt.Sprintf("0/%d", info.ID)
if err := p.utils.QGroupDestroy(ctx, qgroupID, p.Path()); err != nil {
return errors.Wrapf(err, "failed to delete qgroup %s", qgroupID)
// we log here and not return an error because
// - qgroup deletion can fail because it is still used by the system
// even if the volume is gone
// - failure to delete a qgroup is not a fatal error
log.Warn().Err(err).Str("group-id", qgroupID).Msg("failed to delete qgroup")
return nil
}

return nil
Expand Down Expand Up @@ -265,6 +270,7 @@ func (p *btrfsPool) Usage() (usage Usage, err error) {
return
}

// TODO: we need to run this periodically for each pool
func (p *btrfsPool) maintenance() error {
// this method cleans up all the unused
// qgroups that could exists on a filesystem
Expand Down Expand Up @@ -292,7 +298,7 @@ func (p *btrfsPool) maintenance() error {
if !ok {
log.Debug().Str("id", qgroupID).Msg("destroy qgroup")
if err := p.utils.QGroupDestroy(ctx, qgroupID, p.Path()); err != nil {
return err
log.Warn().Err(err).Str("group-id", qgroupID).Msg("failed to destroy unused group")
}
}
}
Expand Down

0 comments on commit 047ff56

Please sign in to comment.