Bug #2696
closedFailed to create a compute vmware (VMWare) instance test12.local.domain: failed to create vm: undefined method `resourcePool' for nil:NilClass
Description
After creating a new vmware compute resource in foreman 1.2 RC3 the first time when I create a new host and hit the Submit button I get an "Unable to Save" error and the host is not created in foreman and vmware.
Unable to save
• Failed to create a compute vmware (VMWare) instance test12.local.domain: failed to create vm: undefined method `resourcePool' for nil:NilClass
But when I hit the Submit button a second time then the host suddenly does get created and saved in foreman and vmware without and error.
I attached debug log with both results in it.
Files
Updated by Ronny M over 11 years ago
Sorry forgot to give info about my setup
VMWare Esxi 5.0.0 managed by VSphere (VMware vCenter Server 5.0.0.16964)
CentOS release 6.2 (Final)
Foreman 1.2 RC3
/bin/cat <<EOF> /usr/share/foreman-installer/foreman_installer/answers.yaml
foreman_proxy:
tftp: true
dhcp: true
puppetrun: true
dns: true
puppetca: true
puppetmaster: true
puppet: true
foreman:
db_manage: true
passenger: true
ssl: true
EOF
Updated by Dominic Cleal over 11 years ago
- Category set to Compute resources
Can you check a couple of things?
- the datacentre listed in the compute resource properties is correct and visible to your user
- the cluster ("thuis") is also when creating the VM
The error implies that Fog tried to search for this datacentre+cluster combination on vSphere and it didn't return a result.
Updated by Ronny M over 11 years ago
Described below are the actions/steps that I perform when encountering the error.
1. Login as admin.
2. Create new compute resource
3. Load datacenter shows the datacenter that I need. (Test connection also succeeds)
4. View virtual machines tab in computer resource also shows virtual machines available in datacenter/cluster
5. I create a new host
6. Datacenter to deploy host on shows the the CJIB datacenter
7. In virtual machine tab cluster thuis is listed and already selected
8. I complete the vm's configuration OS, Network and vm details.
9. Press the submit button and get the save error.
10. Press submit a second time. No error and vm is created in foreman and vmware.
If I choose cancel at step 9. instead of submit and then create a new vm with steps 1 to 9, then also no error occurs and vm is created in foreman and vmware.
It only happens with the first vm that I try to create. It looks like it doesn't has datacenter/cluster info (although its showing it) needed for creating the vm until I hit Submit or cancel on first vm creation.
Updated by Ronny M over 11 years ago
- File production-working.log production-working.log added
- File production-error500.log production-error500.log added
Not sure if it is a bug anymore.
Additional testing appears to reveal that if I wait at least 5 minutes before I try to create the first VM, the vm does get created in foreman and vmware without an error.
Might be because my setup is running in vmware workstation and I switch between snapshots a lot for testing.
Have to note though that this also occurs after a clean install when I finished configuring foreman and immediately create a new vm.
I attached debug log (production-working.log) of scenario when waiting at least 5 minutes before I create vm after revering to a snapshot of a configured foreman and it works.
During testing I also did notice that for created vm's edit button of provision template shows template but the review button results in an error 500. Attached log (production-error500.log) for this error.
The review button of the PXELinux template does not have this problem.
Updated by Ronny M over 11 years ago
I think this one can be closed.
Tried a fresh install + configuration.
This time I waited 10 minutes before I created the first new host after I finished the configuration.
No errors this time.
It's strange but it seems the problem was caused by doing installation, configuration and new host creation to fast in a row.
Updated by Dominic Cleal over 11 years ago
- Status changed from New to Closed
- Target version deleted (
1.2.0)
Very strange, I can't think of a reason why that would be the case.. I had also seen this once while doing #2612, but haven't since and neither did Sam while trying to reproduce it. As you suggest, I'll close it for now. If it keeps coming up, we'll reopen and investigate further.
Thanks for your investigation!
Updated by Marc Grimme about 11 years ago
Hi Dominic,
I think this issue should be reopened cause it constantly happens with my foreman setup (v1.2).
It looks like it is somehow related to the process state of foreman and responsiveness of VMware (as stated before).
Observations:
1st: the exception is triggered by the method call get_raw_cluster(attributes[:cluster], attributes[:datacenter]).resourcePool in fog/vsphere/requests/compute/create_vm.rb (line 20). It looks like the datacenter attribute is empty. This causes getCluster to return nil and there we are.
Whereas when I hit submit a second time on the submit button in foreman the creation of the host is successfully done.
2nd: It looks like this is related to foreman being run as services. When I start foreman from the shell with rails s .. no problems. As soon as I start it either as service or from mod_passenger the problem shows itself.
I have a system where I can test and reproduce this issue.
Any suggestions on how to proceed or which information would be of help for you?
Thanks Marc.
Updated by Dominic Cleal about 11 years ago
I've not really got any suggestions for how to debug this. I think it must be the cluster attribute not being found, as if the datacenter wasn't found then the get_raw_cluster method in lib/fog/vsphere/requests/compute/get_cluster.rb would fail trying to call .find_compute_resource on nil.
The original production.log from Ronny shows that the cluster is correctly passed in via params, so I can only conclude the problem is somewhere on the Fog/rbvmomi or VMware side (e.g. an unreliable query to vSphere). I can't think how Passenger versus WEBrick would affect it either.
Updated by Dominic Cleal about 10 years ago
- Category changed from Compute resources to Compute resources - VMware
Updated by Dominic Cleal almost 10 years ago
- Related to Bug #9779: first host creation submit doesn't work using VMWare compute resource added
Updated by Anonymous over 8 years ago
what's the status here with newer foreman releases?