Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1332652 - CLI - host create produces ISE on providing invalid environment-id
Summary: CLI - host create produces ISE on providing invalid environment-id
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Compute Resources
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Shimon Shtein
QA Contact: Roman Plevka
URL:
Whiteboard:
Depends On: 1343058
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-03 16:21 UTC by Roman Plevka
Modified: 2019-09-26 16:20 UTC (History)
5 users (show)

Fixed In Version: foreman-1.11.0.32-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:07:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 15154 0 None None None 2016-05-24 07:17:36 UTC

Description Roman Plevka 2016-05-03 16:21:33 UTC
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:

Comment 4 Shimon Shtein 2016-05-24 07:17:34 UTC
Created redmine issue http://projects.theforeman.org/issues/15154 from this bug

Comment 5 Bryan Kearney 2016-05-24 08:16:19 UTC
Upstream bug component is Compute Resources

Comment 6 Bryan Kearney 2016-05-24 16:16:52 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15154 has been closed

Comment 9 Roman Plevka 2016-06-02 15:07:36 UTC
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.

Comment 10 Roman Plevka 2016-06-02 15:09:17 UTC
# 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

Comment 12 Bryan Kearney 2016-06-06 12:52:25 UTC
MOving this back to ON_QA, Please test this piece and track the new issue in comment 10.

Comment 13 Roman Plevka 2016-06-07 12:50:15 UTC
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

Comment 14 Bryan Kearney 2016-07-27 11:07:47 UTC
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


Note You need to log in before you can comment on or make changes to this bug.