Uploaded image for project: 'Migration Toolkit for Virtualization'
  1. Migration Toolkit for Virtualization
  2. MTV-1796

When a plan is cancelled and not archived/deleted, the VM in the source will be powered on during reconciliation.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 2.7.10
    • 2.7.5
    • None
    • None
    • False
    • None
    • True
    • Moderate

      Customer has found the following:

      Create Warm Plan 1 with VM A - And get the migration for VM A in a cancel state. (and just kind of ignore it)

      At some point in the future:
      Create Warm Plan 2 with VM A - And successfully complete the migration.  This results in VM A powered off in the source environment.

      When the MTV controller loop runs, it will reconcile plan 1, and detect that the src VM was supposed to be running on the src side, so it starts it back up, regardless of the status of plan 2 (edited) 
       

      Forklift controller pod log showing stacktrace shows that when reconciliation happens, the cancelled migration plan will execute the Cancel function and enter the cleanup function. It will then attempt to delete the snapshot and fail. But it will continue to the next step found in the code further below.

       

      {"level":"error","ts":"2024-12-03 21:03:43.415","logger":"plan|6vf4c","msg":"Failed to clean up warm migration snapshots.","plan":{"name":"20241030-test-test-2","namespace":"openshift-mtv"},"vm":" id:vm-7479091 name:'test' ","error":"no snapshots for this VM","stacktrace":"github.com/konveyor/forklift-controller/pkg/controller/plan.(*Migration).removeLastWarmSnapshot\n\t/remote-source/app/pkg/controller/plan/migration.go:522\ngithub.com/konveyor/forklift-controller/pkg/controller/plan.(*Migration).cleanup\n\t/remote-source/app/pkg/controller/plan/migration.go:507\ngithub.com/konveyor/forklift-controller/pkg/controller/plan.(*Migration).Cancel\n\t/remote-source/app/pkg/controller/plan/migration.go:432\ngithub.com/konveyor/forklift-controller/pkg/controller/plan.(*Reconciler).execute\n\t/remote-source/app/pkg/controller/plan/controller.go:389\ngithub.com/konveyor/forklift-controller/pkg/controller/plan.Reconciler.Reconcile\n\t/remote-source/app/pkg/controller/plan/controller.go:257\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227"}

       

      https://github.com/kubev2v/forklift/blob/main/pkg/controller/plan/migration.go#L433

       

      // Cancel the migration.
      // Delete resources associated with VMs that have been marked canceled.
      func (r *Migration) Cancel() error {
          if err := r.init(); err != nil {
              return liberr.Wrap(err)
          }
          for _, vm := range r.Plan.Status.Migration.VMs {
              if vm.HasCondition(Canceled) {
                  dontFailOnError := func(err error) bool {
                      if err != nil {
                          r.Log.Error(liberr.Wrap(err),
                              "Couldn't clean up after canceled VM migration.",
                              "vm",
                              vm.String())
                      }
                      return false
                  }
                  _ = r.cleanup(vm, dontFailOnError)
                  if vm.RestorePowerState == plan.VMPowerStateOn {
                      if err := r.provider.PowerOn(vm.Ref); err != nil {
                          r.Log.Error(err,
                              "Couldn't restore the power state of the source VM.",
                              "vm",
                              vm.String())
                      }
                  }
                  vm.MarkCompleted()
                  markStartedStepsCompleted(vm)
              }
          }
          return nil
      }
      

       

              Unassigned Unassigned
              shaselde@redhat.com Sean Haselden
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: