Skip to content

improve network lookup for vmware source imports #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/apis/migration.harvesterhci.io/v1beta1/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions pkg/apis/migration.harvesterhci.io/v1beta1/virtualmachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type VirtualMachineImportSpec struct {

Folder string `json:"folder,omitempty"`

// If empty new VirtualMachineImport will be mapped to Management Network.
// If empty, new VirtualMachineImport will be mapped to Management Network.
Mapping []NetworkMapping `json:"networkMapping,omitempty"`
// The default network interface model. This is always used when:
// - Auto-detection fails (OpenStack source client does not have auto-detection, therefore this field is used for every network interface).
Expand All @@ -46,7 +46,7 @@ type VirtualMachineImportSpec struct {

// The bus type that is used for imported disks if auto-detection fails.
// Note, the OpenStack source client does not support auto-detection,
// therefore it always makes use of this field.
// therefore, it always makes use of this field.
// Defaults to "virtio".
DefaultDiskBusType *kubevirtv1.DiskBus `json:"defaultDiskBusType,omitempty"`

Expand All @@ -63,6 +63,11 @@ type VirtualMachineImportSpec struct {
// Defaults to 60 seconds.
// Please note that this field only applies to VMware imports.
GracefulShutdownTimeoutSeconds int32 `json:"gracefulShutdownTimeoutSeconds,omitempty"`

// +optional
// SkipPreflightChecks allows you to forcefully skip the preflight checks.
// Defaults to false.
SkipPreflightChecks *bool `json:"skipPreflightChecks,omitemtpy"`
}

// VirtualMachineImportStatus tracks the status of the VirtualMachineImport export from migration and import into the Harvester cluster
Expand Down Expand Up @@ -171,6 +176,10 @@ func (in *VirtualMachineImport) NamespacedName() string {
}.String()
}

func (in *VirtualMachineImport) SkipPreflightChecks() bool {
return ptr.Deref(in.Spec.SkipPreflightChecks, false)
}

func (in *NetworkMapping) GetNetworkInterfaceModel() string {
return ptr.Deref(in.NetworkInterfaceModel, NetworkInterfaceModelVirtio)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions pkg/controllers/migration/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,23 @@ func (h *virtualMachineHandler) preFlightChecks(vm *migration.VirtualMachineImpo
if err != nil {
return fmt.Errorf("error generating VMO in preFlightChecks: %v", err)
}
err = vmo.PreFlightChecks(vm)
if err != nil {

if vm.SkipPreflightChecks() {
logrus.WithFields(logrus.Fields{
"name": vm.Name,
"namespace": vm.Namespace,
"spec.sourcecluster.kind": vm.Spec.SourceCluster.Kind,
}).Errorf("Failed to perform source cluster specific preflight checks: %v", err)
return err
}).Info("skipping preflight checks")
} else {
err = vmo.PreFlightChecks(vm)
if err != nil {
logrus.WithFields(logrus.Fields{
"name": vm.Name,
"namespace": vm.Namespace,
"spec.sourcecluster.kind": vm.Spec.SourceCluster.Kind,
}).Errorf("Failed to perform source cluster specific preflight checks: %v", err)
return err
}
}

return nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading