Cannot create VM over API on Xen Orchestra: vdi.destroy handle_invalid

Hello,

after a search in the dark I found the error. Everythign revolves around this function:

    285     def create_vm(args = {})
      [...]
    328 
    329         # Write XenStore data
    330         xenstore_data = xenstore_set_mac(vm, args[:xenstore])
    331         set_xenstore_data(vm, xenstore_data)
    332 
    333         # Fix Description
    334         vm.set_attribute('name-description', args[:name_description])
    335 
    336         return vm
    337       rescue => e
    338         logger.info e #this line does not exist in the source
    339         cleanup_configdrive(vm.uuid) if vm&.uuid
    340         vm&.destroy
    341         vm.volumes.each(&:destroy) if vm&.volumes
    342         logger.info e
    343         logger.info e.backtrace.join("\n")
    344         raise e
    345       end
    346     end

I was mislead by the error that was generated in line 339. This error message was from the cleanup, not from the failed call to Xen. After moving logger.info e at the top of rescue I finally got an error message generated in line 334. This call fails because the arg “description” is set to null and is not passed. Setting it to an empty string by providing the “comment” arg inside the API call fixes everything.

I might create a patch because the error logging here is not well constructed.

1 Like