Bug #19990

Failed to update a compute vmware (VMware) instance node.test.domain: undefined method `[]' for nil:NilClass

Added by Christian Meißner 3 months ago. Updated 13 days ago.

Status:New
Priority:High
Assigned To:-
Category:Compute resources - VMware
Target version:Team Marek backlog
Difficulty: Bugzilla link:
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

If I try to update the environment of a machine in a vmware compute instance i get the above error.

I attached the sanitized debug output of the following command.

hammer -u user -p pass -d host update --id 127 --environment production

If I use --environment-id instead of --environment it leads to the same error.

Other actions for example start and stop of a virtual machine works fine.

hammer_cli_debug.log (6.62 KB) Christian Meißner, 06/13/2017 05:00 AM

production.log (23.3 KB) Christian Meißner, 06/14/2017 01:10 AM

production.log (472 KB) Steven Miller, 06/15/2017 03:02 PM

guiheader.txt Magnifier - Header sent when submitted request to create new host (3.78 KB) Steven Miller, 06/15/2017 03:02 PM

History

#1 Updated by Tomáš Strachota 3 months ago

Hello Christian,
thank you for reporting the issue. Attached hammer logs show that the error occurs on the server side. May I ask you to attach relevant part of foreman logs too?
If you try to perform the same action in the UI, does it fail with the same error?

#2 Updated by Christian Meißner 3 months ago

Tomáš Strachota wrote:

Hello Christian,
thank you for reporting the issue. Attached hammer logs show that the error occurs on the server side. May I ask you to attach relevant part of foreman logs too?

Hi Tomas attached you can find the cut off of our production.log.

If you try to perform the same action in the UI, does it fail with the same error?

No, in the UI it works pretty good.

#3 Updated by Tomáš Strachota 3 months ago

  • Project changed from Hammer CLI to Foreman
  • Category changed from Hosts to Compute resources - VMware

I'm switching the component to VMWare as this is a server side API issue. The compute node orchestration fails on update via API because it misses some compute attribute data. UI works fine because it loads the compute attributes into the form when the page is rendered and then when user hits update the request is sent with required parameters. In API the only workaround is to send the fill set of current compute attributes with the update request.

#4 Updated by Tomáš Strachota 3 months ago

  • Target version set to Team Marek backlog

#5 Updated by Tomáš Strachota 3 months ago

Most likely introduced with https://github.com/theforeman/foreman/pull/4146/
oVirt is probably affected too.

#6 Updated by Marek Hulán 3 months ago

  • Release set to 1.15.2

I suppose this is a candidate for 1.15.2 then. Please reset the Release if you disagree.

#7 Updated by Steven Miller 3 months ago

I am seeing the same bug on this provider, even when provisioning a new system from the GUI. I've attached my production logs, along with the final form data that is submitted when attempting to create a host. On the VMware side the actual VM is created, but then when it hits the "undefined method" error it rolls back the VMware machine (but not the record within foreman)

#8 Updated by Daniel Lobato Garcia 3 months ago

  • Release changed from 1.15.2 to 1.15.3

#9 Updated by Daniel Lobato Garcia about 1 month ago

  • Release changed from 1.15.3 to 1.15.4

#10 Updated by Marek Hulán 14 days ago

Tomas, why do you think it was introduced by the linked PR? According to the trace, it seems that compute_attrs for a given VM are nil. Based on incoming parameters, they are part of API request. I don't see how attributes can become nil so far

Parameters: {"host"=>{"environment_id"=>20, "compute_attributes"=>{"volumes_attributes"=>{}}, "host_parameters_attributes"=>{}, "interfaces_attributes"=>{}}, "apiv"=>"v2", "id"=>"119"}

#11 Updated by Tomáš Strachota 13 days ago

Marek, the issue has actually been there even before the commit I mentioned, but this change eventually exposed the buggy code to users:
https://github.com/theforeman/foreman/pull/4146/files#diff-4443c0de1e4e867a30d3c878b9cb64e9R24

Before that it wasn't possible to update attribute of existing VMs on vmWare. From the traceback, the process fails on:
https://github.com/theforeman/foreman/blob/c952c782adac290fd5a1145090380424665f5fe1/app/models/compute_resources/foreman/model/vmware.rb#L434
(please note that the bug was reported against the foreman 1.15 and line numbers have been shifted since then)

So the issue isn't caused by compute_attributes being nil, but by volume attributes that can't be found. The code isn't prepared for partial updates and always requires the full set of compute attributes (including volumes and nics). The reason it works in the UI is that the host edit form pre-loads current compute attributes and therefore the attributes are complete.

#12 Updated by Marek Hulán 13 days ago

  • Release deleted (1.15.4)

Now that makes more sense, thanks for clarification. I suppose this is API RFE then, removing from 1.15.4

Also available in: Atom PDF