Skip to content

Fix undeployed VMs breaking ansible inventory

Adrien Kohlbecker requested to merge ak/fix-undeployed into master

This is the contents of the vm_resource hashes for a deployed VM and an undeployed VM:

{'virtual_machine_name': 'ak', 'vm_deployment_status': 'Not Deployed', 'owner': 'akohlbecker@gitlab.com', 'cpu': 12, 'vcpu': 12, 'base_image': '90GCatalinaSSH.img', 'image': 'ak', 'configuration_template': 'default'}

{'virtual_machine_name': 'test', 'vm_deployment_status': 'Deployed', 'status': [{'owner': 'akohlbecker@gitlab.com', 'virtual_machine_name': 'test', 'virtual_machine_id': '18f750e015b10', 'node_location': 'macpro-105', 'node_status': 'UP', 'virtual_machine_ip': '10.221.188.115', 'vnc_port': '6001', 'screen_sharing_port': '5902', 'ssh_port': '8824', 'cpu': 3, 'vcpu': 3, 'RAM': '7.5G', 'base_image': '90GCatalinaSSH.img', 'image': 'test', 'configuration_template': 'default', 'vm_status': 'running', 'reserved_ports': [{'host_port': 6001, 'guest_port': 5999, 'protocol': 'TCP'}, {'host_port': 5902, 'guest_port': 5900, 'protocol': 'TCP'}, {'host_port': 8824, 'guest_port': 8821, 'protocol': 'TCP'}], 'creation_timestamp': '2020-11-24T17:23:23Z'}]}

We need to ignore the former in the inventory script, as it results in the following error: https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka/-/jobs/870058426

Traceback (most recent call last):
  File "./inventory/orka.py", line 419, in <module>
    OrkaInventory()
  File "./inventory/orka.py", line 195, in __init__
    json_data = self.load_vm_variables_for_host()
  File "./inventory/orka.py", line 338, in load_vm_variables_for_host
    statuses = vm_resource['status']
KeyError: 'status'
Edited by Adrien Kohlbecker

Merge request reports