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

fix possible dm snapshot leaks #381

Merged
merged 2 commits into from
Sep 3, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
deactive dm snapshots if a vm is removed
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
  • Loading branch information
chanwit committed Aug 31, 2019
commit 6704273040a474c066715cd60510666bdd6124cb
11 changes: 9 additions & 2 deletions pkg/operations/remove.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (
log "github.com/sirupsen/logrus"
api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/client"
"github.com/weaveworks/ignite/pkg/dmlegacy/cleanup"
"github.com/weaveworks/ignite/pkg/logs"
"github.com/weaveworks/ignite/pkg/providers"
"github.com/weaveworks/ignite/pkg/runtime"
@@ -28,7 +29,7 @@ func DeleteVM(c *client.Client, vm *api.VM) error {
// CleanupVM removes the resources of the given VM
func CleanupVM(vm *api.VM) error {
// Inspect the container before trying to stop it and it gets auto-removed
result, _ := providers.Runtime.InspectContainer(util.NewPrefixer().Prefix(vm.GetUID()))
inspectResult, _ := providers.Runtime.InspectContainer(util.NewPrefixer().Prefix(vm.GetUID()))

// If the VM is running, try to kill it first so we don't leave dangling containers
if vm.Running() {
@@ -38,7 +39,13 @@ func CleanupVM(vm *api.VM) error {
}

// Remove the VM container if it exists
RemoveVMContainer(result)
// TODO should this function return a proper error?
RemoveVMContainer(inspectResult)

// After removal is successful, remove the dm snapshots
if err := cleanup.DeactivateSnapshot(vm); err != nil {
return err
}

if logs.Quiet {
fmt.Println(vm.GetUID())