Skip to content
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

Enhance importer to handle several issue #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

votdev
Copy link
Member

@votdev votdev commented Sep 10, 2024

Problem:

  • Import OpenStack server by UUID results in ugly VM name in Harvester
  • Import OpenStack server with upper case characters in its name is not possible

Solution:
The following improvements have been done:

  • Sanitize the configured VirtualMachineName field, e.g. convert upper case to lower case to make it RFC 1123 compliant.
  • Convert UUID to real name for OpenStack imports
  • Reduce waiting time to recheck if created VM is running from 5min to 2min
  • Rename variable uuid to serverUUID in the OpenStack client code to do not collide with the imported uuid module
  • Improve log messages
  • Fix typos
  • Add comments

Related Issue:
harvester/harvester#6500
harvester/harvester#6505
harvester/harvester#6673

Test plan:

Preparations

  1. Create Secret, OpenstackSource and VmwareSource resources to access our test servers.
  2. Create a Virtual Machines Network named vlan1 in the default namespace in Harvester.

Test case 1:

  • Create the following VirtualMachineImport and import it.
apiVersion: migration.harvesterhci.io/v1beta1
kind: VirtualMachineImport
metadata:
  name: cirros-tiny
  namespace: default
spec:
  virtualMachineName: "cirros-tiny"
  networkMapping:
  - sourceNetwork: "shared"
    destinationNetwork: "default/vlan1"
  sourceCluster:
    name: devstack
    namespace: default
    kind: OpenstackSource
    apiVersion: migration.harvesterhci.io/v1beta1
  • A VM named cirros-tiny should be created in Harvester.
  • You should see the following output in the vm-import-controller log:
time="2024-09-10T12:25:53Z" level=info msg="The sanitization of the 'VirtualMachineImport' object was successful" name=cirros-tiny namespace=default spec.virtualMachineName=cirros-tiny status.definiteVirtualMachineName=cirros-tiny
time="2024-09-10T12:25:53Z" level=info msg="Power off the source VM" name=cirros-tiny namespace=default spec.sourceCluster.kind=OpenstackSource spec.sourceCluster.name=devstack spec.virtualMachineName=cirros-tiny status.definiteVirtualMachineName=cirros-tiny
time="2024-09-10T12:25:58Z" level=info msg="Exporting source VM" name=cirros-tiny namespace=default spec.sourceCluster.kind=OpenstackSource spec.sourceCluster.name=devstack spec.virtualMachineName=cirros-tiny status.definiteVirtualMachineName=cirros-tiny
time="2024-09-10T12:26:03Z" level=info msg="&{6c6cfbdc-xxxx-xxxx-xxxx-1d4d060420fa creating 1 nova 2024-09-10 12:26:03.198052 +0000 UTC 0001-01-01 00:00:00 +0000 UTC ]   lvmdriver-1 2d7f59c9-xxxx-xxxx-xxxx-71116eb42fd1  map] ace422xxxx088af true false   false}"
time="2024-09-10T12:26:07Z" level=info msg="Create a new image from a volume" attachedVolumeID=cee6186b-xxxx-xxxx-xxxx-86ac3b2dc16b name=cirros-tiny namespace=default spec.sourceCluster.kind=OpenstackSource spec.sourceCluster.name=devstack spec.virtualMachineName=cirros-tiny
time="2024-09-10T12:26:19Z" level=info msg="Download the image" imageID=9e092383-xxxx-xxxx-xxxx-749b38bbf023 name=cirros-tiny namespace=default spec.sourceCluster.kind=OpenstackSource spec.sourceCluster.name=devstack spec.virtualMachineName=cirros-tiny
time="2024-09-10T12:29:38Z" level=info msg="vm cirros-tiny in namespace default imported successfully"

Test case 2:

  • Create the following VirtualMachineImport and import it.
apiVersion: migration.harvesterhci.io/v1beta1
kind: VirtualMachineImport
metadata:
  name: cirros-tiny-uuid
  namespace: default
spec:
  virtualMachineName: "dd952f47-6930-4d65-a702-0f7121b31c8f"
  networkMapping:
  - sourceNetwork: "shared"
    destinationNetwork: "default/vlan1"
  sourceCluster:
    name: devstack
    namespace: default
    kind: OpenstackSource
    apiVersion: migration.harvesterhci.io/v1beta1
  • A VM named cirros-tiny should be created in Harvester.

Test case 3:

  • Create the following VirtualMachineImport and import it.
apiVersion: migration.harvesterhci.io/v1beta1
kind: VirtualMachineImport
metadata:
  name: foo-bar
  namespace: default
spec:
  virtualMachineName: "foo-Bar"
  networkMapping:
  - sourceNetwork: "shared"
    destinationNetwork: "default/vlan1"
  sourceCluster:
    name: devstack
    namespace: default
    kind: OpenstackSource
    apiVersion: migration.harvesterhci.io/v1beta1
  • A VM named foo-bar should be created in Harvester.

Test case 4:

  • Create the following VirtualMachineImport and import it.
apiVersion: migration.harvesterhci.io/v1beta1
kind: VirtualMachineImport
metadata:
  name: mr-leap1
  namespace: default
spec: 
  virtualMachineName: "mr-leap1"
  networkMapping:
  - sourceNetwork: "VM Network"
    destinationNetwork: "default/vlan1"
  sourceCluster: 
    name: vcsim
    namespace: default
    kind: VmwareSource
    apiVersion: migration.harvesterhci.io/v1beta1
  • A VM named mr-leap1 should be created in Harvester. Note, the export from the VMWare server might take a long time.
  • You should see the following output in the vm-import-controller log:
time="2024-09-10T13:24:16Z" level=info msg="The sanitization of the 'VirtualMachineImport' object was successful" name=mr-leap1 namespace=default spec.virtualMachineName=mr-leap1 status.definiteVirtualMachineName=mr-leap1
time="2024-09-10T13:24:17Z" level=info msg="Power off the source VM" name=mr-leap1 namespace=default spec.sourceCluster.kind=VmwareSource spec.sourceCluster.name=vcsim spec.virtualMachineName=mr-leap1 status.definiteVirtualMachineName=mr-leap1
time="2024-09-10T13:24:24Z" level=info msg="Exporting source VM" name=mr-leap1 namespace=default spec.sourceCluster.kind=VmwareSource spec.sourceCluster.name=vcsim spec.virtualMachineName=mr-leap1 status.definiteVirtualMachineName=mr-leap1
time="2024-09-10T13:24:26Z" level=info msg="Downloading an image" deviceId="/vm-2375/ParaVirtualSCSIController0:0" name=mr-leap1 namespace=default path=mr-leap1-default-disk-0.vmdk size=48318382080 spec.sourceCluster.kind=VmwareSource spec.sourceCluster.name=vcsim spec.virtualMachineName=mr-leap1
time="2024-09-10T13:50:12Z" level=info msg="Skipping an image" deviceId="/vm-2375/VirtualIDEController0:0" name=mr-leap1 namespace=default path=disk-1.iso size=4631560192 spec.sourceCluster.kind=VmwareSource spec.sourceCluster.name=vcsim spec.virtualMachineName=mr-leap1
time="2024-09-10T13:50:12Z" level=info msg="Skipping an image" deviceId=/vm-2375/nvram name=mr-leap1 namespace=default path=disk-2.nvram size=8684 spec.sourceCluster.kind=VmwareSource spec.sourceCluster.name=vcsim spec.virtualMachineName=mr-leap1
time="2024-09-10T13:50:12Z" level=info msg="converting image /tmp/mr-leap1-default-981004653/mr-leap1-default-disk-0.vmdk to /tmp/vm-import-controller/mr-leap1-default-disk-0.img"
time="2024-09-10T14:08:39Z" level=info msg="vm mr-leap1 in namespace default imported successfully"

- Import OpenStack server by UUID
- Import OpenStack server with upper case characters in its name

The following improvements have been done:
- Sanitize the configured `VirtualMachineName` field, e.g. convert upper case to lower case to make it RFC 1123 compliant.
- Convert UUID to real name for OpenStack imports
- Reduce waiting time to recheck if created VM is running from 5min to 2min
- Rename variable `uuid` to `serverUUID` in the OpenStack client code to do not collide with the imported uuid module
- Improve log messages
- Fix typos
- Add comments

Related to: harvester/harvester#6500
Related to: harvester/harvester#6505

Signed-off-by: Volker Theile <[email protected]>
@votdev votdev force-pushed the issue_6500_6505_sanitize_vm_name branch from 7daf5da to cbca0b8 Compare October 9, 2024 10:11
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.

1 participant