Hide Forgot
Description of problem: in the below example i provide environment-id="122" which does not exist: <pre> # hammer -v -u admin -p changeme --output=csv host create --medium-id="9" --root-pass="changeme" --organization-id="1" --location-id="2" --architecture-id="1" --puppet-proxy-id="1" --name="foo4" --environment-id="122" --compute-resource-id="1" --domain-id="1" --operatingsystem-id="3" --partition-table-id="61" [ERROR 2016-05-03 18:14:15 Exception] ERROR: insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk" DETAIL: Key (environment_id)=(122) is not present in table "environments". Could not create the host: ERROR: insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk" DETAIL: Key (environment_id)=(122) is not present in table "environments". </pre> after retrigerring the same command with the correct environment id, I'm no longer able to use the same name for the host (ending up with different error): <pre> # hammer -v -u admin -p changeme --output=csv host create --medium-id="9" --root-pass="changeme" --organization-id="1" --location-id="2" --architecture-id="1" --puppet-proxy-id="1" --name="foo4" --environment-id="1" --compute-resource-id="1" --domain-id="1" --operatingsystem-id="3" --partition-table-id="61" [ERROR 2016-05-03 18:17:48 Exception] Failed to create a compute my_libvirt_cr_1 (Libvirt) instance foo4.domain.com: no implicit conversion of nil into String Could not create the host: Failed to create a compute my_libvirt_cr_1 (Libvirt) instance foo4.domain.com: no implicit conversion of nil into String </pre> Version-Release number of selected component (if applicable): 6.2.0 BETA How reproducible: always Steps to Reproduce: 1. create all the prerequisites for creating a host (OS, arch, partition table, ...) 2. try to create the host with providing invalid environment-id [3. optionally, try to create the host again with using the same name] Actual results: ERROR: insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk" Expected results: user friendly message displayed, nothing is being created on the satellite side. Additional info:
Created redmine issue http://projects.theforeman.org/issues/15154 from this bug
Upstream bug component is Compute Resources
Moving to POST since upstream bug http://projects.theforeman.org/issues/15154 has been closed
FAILED QA: on sat6.2.0 beta (GA14.0) - the patch fixed the 'no implicit conversion of nil into String' error. However the VM is now being created even if wrong Environment is specified and error returned. The VM exists on the Compute resource as shutoff and unmanaged, preventing the 2nd run (with corrected Environment ID) to pass (name already taken). - there should be no action taken until valid parameters are handed over.
# hammer host create --name my-cli-host-1 --partition-table-id 61 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9 [Foreman] Password for admin: Could not create the host: ERROR: insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk" DETAIL: Key (environment_id)=(999) is not present in table "environments". [root@sat6 dhcp]# [root@sat6 dhcp]# [root@sat6 dhcp]# hammer host create --name my-cli-host-1 --partition-table-id 61 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9 [Foreman] Password for admin: Could not create the host: Failed to create a compute my_libvirt_cr_1 (Libvirt) instance my-cli-host-1.domain.com: Error saving the server: Call to virDomainDefineXML failed: operation failed: domain 'my-cli-host-1.domain.com' already exists with uuid 3d1ac10d-fb73-fb16-a3a3-503d7625e042
Opened a separate issue for comment 10 (https://bugzilla.redhat.com/show_bug.cgi?id=1332652#c10) https://bugzilla.redhat.com/show_bug.cgi?id=1343058
MOving this back to ON_QA, Please test this piece and track the new issue in comment 10.
VERIFIED on sat6.2.0 beta (GA14.2) 2nd run: hammer -v -u admin -p changeme --output=csv host create --medium-id="9" --root-pass="changeme" --organization-id="1" --location-id="2" --architecture-id="1" --puppet-proxy-id="1" --name="foo4" --environment-id="1" --compute-resource-id="1" --domain-id="1" --operatingsystem-id="3" --partition-table-id="61" [ERROR 2016-06-07 08:47:20 Exception] Failed to create a compute my_libvirt_cr_1 (Libvirt) instance my.sat6.server.com: Error saving the server: Call to virDomainDefineXML failed: operation failed: domain 'my.sat6.server.com' already exists with uuid 7d2711e5-51c4-4dc6-9918-629039a635f4 Could not create the host: Failed to create a compute my_libvirt_cr_1 (Libvirt) instance my.sat6.server.com: Error saving the server: Call to virDomainDefineXML failed: operation failed: domain 'my.sat6.server.com' already exists with uuid 7d2711e5-51c4-4dc6-9918-629039a635f4
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2016:1501