Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Ignore not found error while deactivating snapshot #823

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pkg/dmlegacy/deactivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/nightlyone/lockfile"

api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/util"
)

// dmsetupNotFound is the error message when dmsetup can't find a device.
const dmsetupNotFound = "No such device or address"

// DeactivateSnapshot deactivates the snapshot by removing it with dmsetup
func DeactivateSnapshot(vm *api.VM) error {
// Global lock path.
Expand Down Expand Up @@ -42,6 +46,13 @@ func DeactivateSnapshot(vm *api.VM) error {
dmArgs = append(dmArgs, baseDev)
}

_, err = util.ExecuteCommand("dmsetup", dmArgs...)
return err
if _, err := util.ExecuteCommand("dmsetup", dmArgs...); err != nil {
// If the device is not found, it's been deleted already, return nil.
if strings.Contains(err.Error(), dmsetupNotFound) {
return nil
}
return err
}

return nil
}