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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ibrokethecloud
Copy link
Collaborator

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Problem:

Imports from vmware source where the VM is using a network backed by a Dswitch get mapped to pod network and not the correct target vlan in harvester.

This happens because of the way summary of a nic is represented when using a dswitch backed network.

Solution:

Add additional logic in the vmware import process to identify backing device for a nic and process network names accordingly.

In case of dswitched backed networks we identify the PortGroupKey for nic and use the same to lookup actual vm network name.

Related Issue:
harvester/harvester#7774
Test plan:

  • import a vm from vmware where the VM is using dswitch backed network
  • ensure the vm has a valid source to destination network mapping
  • post import the VM should have been mapped to the correct target vm network

@ibrokethecloud ibrokethecloud force-pushed the tweak-vmware-network-lookup branch from 0807758 to cd068e6 Compare March 7, 2025 02:01
… vm's to allow importing of VM's using Dswitch backed networks

change how network name lookup is perform when importing vmware based vm's to allow importing of VM's using Dswitch backed networks
@ibrokethecloud ibrokethecloud force-pushed the tweak-vmware-network-lookup branch from cd068e6 to 2ff4763 Compare March 7, 2025 03:15
case *types.VirtualEthernetCardNetworkBackingInfo:
obj := b
summary = obj.DeviceName
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return variable is already set to empty, but to simplify reading the code I would add a default case to the switch statement. In this case it is totally clear what happens.

Suggested change
}
default:
summary = ""
}

votdev
votdev previously approved these changes Mar 10, 2025
Copy link
Member

@votdev votdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM + the small suggestion

innobead
innobead previously approved these changes Mar 10, 2025
starbops
starbops previously approved these changes Mar 14, 2025
Copy link
Member

@starbops starbops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@ibrokethecloud
Copy link
Collaborator Author

waiting on feedback from end user who is running a dev build to validate the changes

@ibrokethecloud ibrokethecloud dismissed stale reviews from starbops, innobead, and votdev via 5eadbfd April 15, 2025 00:18
@@ -92,4 +92,5 @@ const (
VirtualMachineImageFailed condition.Cond = "VirtualMachineImageFailed"
VirtualMachineExportFailed condition.Cond = "VMExportFailed"
VirtualMachineMigrationFailed ImportStatus = "VMMigrationFailed"
SkipPreflightChecks string = "harvesterhci.io/skip-preflight-checks"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you prefer using an annotation over adding a new field to VirtualMachineImportSpec?

@@ -91,6 +93,11 @@ func NewClient(ctx context.Context, endpoint string, dc string, secret *corev1.S
vmwareClient.ctx = ctx
vmwareClient.Client = c
vmwareClient.dc = dc
networkMap, err := GenerateNetworkMapByRef(ctx, c.Client)
if err != nil {
return nil, fmt.Errorf("error generating network map during client initialisation: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("error generating network map during client initialisation: %v", err)
return nil, fmt.Errorf("error generating network map during client initialisation: %w", err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants