Skip to content

Commit

Permalink
Fix migration to remote cluster
Browse files Browse the repository at this point in the history
Issue:
During the refactoring I have enabled the server, via which we expose the
virt-v2v gathered information to the controller, to both migraiton
types. The flow is that we request all nessasry information form pod and
then manually kill it from the controller. But right now we can't
reuqest the server which are in remote clusters.

Fix:
Disable the server in the remote migrations. This will cause the pod to
be terminated and the controller will check the pod status and will
continue if the pod succeded.

Note:
Because of this we can't get the OS nor Firmware form the remote
migrations. This should not be a large issue as we use them right
now only for prefenrace in kubevirt.

Signed-off-by: Martin Necas <[email protected]>
  • Loading branch information
mnecas committed Sep 20, 2024
1 parent db6782b commit fa48f09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
7 changes: 6 additions & 1 deletion pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,12 @@ func (r *KubeVirt) guestConversionPod(vm *plan.VMStatus, vmVolumes []cnv.Volume,
Value: vm.NewName,
})
}

environment = append(environment,
core.EnvVar{
Name: "LOCAL_MIGRATION",
Value: strconv.FormatBool(r.Destination.Provider.IsHost()),
},
)
// pod annotations
annotations := map[string]string{}
if r.Plan.Spec.TransferNetwork != nil {
Expand Down
28 changes: 19 additions & 9 deletions virt-v2v/cmd/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"os/exec"
"strconv"
"strings"

"github.com/konveyor/forklift-controller/virt-v2v/pkg/customize"
Expand All @@ -18,7 +19,8 @@ import (
func main() {
var err error
if err = virtV2VPrepEnvironment(); err != nil {
return
fmt.Println("Failed to prepare the environment", err)
os.Exit(1)
}

// virt-v2v or virt-v2v-in-place
Expand All @@ -39,27 +41,35 @@ func main() {
fmt.Println("Failed to get linked disk", err)
os.Exit(1)
}

err = runVirtV2VInspection(disks)
if err != nil {
fmt.Println("Failed to inspect the disk", err)
os.Exit(1)
}
inspection, err := utils.GetInspectionV2vFromFile(global.INSPECTION)
if err != nil {
return
fmt.Println("Failed to get inspection file", err)
os.Exit(1)
}

// virt-customize
err = customize.Run(disks, inspection.OS.Osinfo)
if err != nil {
fmt.Println("Error to customize the VM:", err)
os.Exit(1)
}

err = server.Start()
if err != nil {
fmt.Println("Failed to run the server", err)
os.Exit(1)
if val, found := os.LookupEnv("LOCAL_MIGRATION"); found {
isLocalMigration, err := strconv.ParseBool(val)
if err != nil {
fmt.Println("Failed to parse the 'LOCAL_MIGRATION' environment variable.", err)
os.Exit(1)
}
if isLocalMigration {
err = server.Start()
if err != nil {
fmt.Println("Failed to run the server", err)
os.Exit(1)
}
}
}
}

Expand Down

0 comments on commit fa48f09

Please sign in to comment.