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 1484102 - hammer host creation should handle non-existant os id instead of PG:Error
Summary: hammer host creation should handle non-existant os id instead of PG:Error
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On: 1354568
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-22 17:02 UTC by Kedar Bidarkar
Modified: 2019-08-12 14:06 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-09-04 17:44:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1354568 0 unspecified CLOSED creating a hostgroup with invalid id option should raise proper error instead of foreign key constraint error 2021-02-22 00:41:40 UTC

Internal Links: 1354568

Description Kedar Bidarkar 2017-08-22 17:02:56 UTC
Description of problem:

hammer -u admin -p changeme  host create --name='rhel-7-libvirt12' --root-password='changeme' --organization-id="1" --location-id="2" --hostgroup="RHEL 7 Server 64-bit HG" --compute-resource="libvirt" --compute-attributes="cpus=1, memory=1073741824, start=1" --interface="primary=true, compute_type=bridge, compute_bridge=katello_latest, compute_model=virtio" --volume="capacity=10G,format_type=qcow2" --operatingsystem-id 3 --pxe-loader 'PXELinux BIOS'
Could not create the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_operatingsystem_id_fk"
  DETAIL:  Key (operatingsystem_id)=(3) is not present in table "operatingsystems".




2017-08-22 09:07:24 8d37cb27 [app] [I] Started POST "/api/hosts" for 127.0.0.1 at 2017-08-22 09:07:24 -0400
2017-08-22 09:07:24 8d37cb27 [app] [I] Processing by Api::V2::HostsController#create as JSON
2017-08-22 09:07:24 8d37cb27 [app] [I]   Parameters: {"host"=>{"name"=>"rhel-7-libvirt12", "location_id"=>2, "organization_id"=>1, "operatingsystem_id"=>3, "pxe_loader"=>"PXELinux BIOS", "compute_resource_id"=>1, "hostgroup_id"=>2, "build"=>true, "enabled"=>true, "managed"=>true, "compute_attributes"=>{"cpus"=>"1", "memory"=>"1073741824", "start"=>"1", "volumes_attributes"=>{"0"=>{"capacity"=>"10G", "format_type"=>"qcow2"}}}, "content_facet_attributes"=>{}, "subscription_facet_attributes"=>{}, "overwrite"=>true, "host_parameters_attributes"=>[], "interfaces_attributes"=>[{"primary"=>"true", "compute_attributes"=>{"type"=>"bridge", "bridge"=>"katello_latest", "model"=>"virtio"}}], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"}
2017-08-22 09:07:24 8d37cb27 [app] [I] Current user: foreman_admin (administrator)
2017-08-22 09:07:24 8d37cb27 [app] [I] Current user: foreman_admin (administrator)
2017-08-22 09:07:24 8d37cb27 [app] [I] Current user: admin (administrator)
2017-08-22 09:07:24 8d37cb27 [app] [I] Authorized user admin(Admin User)
2017-08-22 09:07:24 8d37cb27 [app] [I] Current user: admin (administrator)
2017-08-22 09:07:28 8d37cb27 [app] [I] Add DNS A record for rhel-7-lhost1-name.redhat.com/10.x.x.x
2017-08-22 09:07:28 8d37cb27 [app] [I] Add DNS PTR record for rhel-7-lhost1-name.redhat.com
2017-08-22 09:07:29 8d37cb27 [app] [W] Rolling back due to exception during save
 | ActiveRecord::InvalidForeignKey: PG::Error: ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_operatingsystem_id_fk"
 | DETAIL:  Key (operatingsystem_id)=(3) is not present in table "operatingsystems".
 | : INSERT INTO "hosts" ("type", "build", "compute_resource_id", "managed", "root_pass", "pxe_loader", "hostgroup_id", "location_id", "operatingsystem_id", "organization_id", "puppet_proxy_id", "puppet_ca_proxy_id", "environment_id", "name", "owner_id", "owner_type", "architecture_id", "ptable_id", "grub_pass", "lookup_value_matcher", "uuid", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23) RETURNING "id"
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:602:in `exec_prepared'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:602:in `block in exec_cache'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'



Version-Release number of selected component (if applicable):

Sat6.3.0-snap12.0

How reproducible:


Steps to Reproduce:
1. Create a host with non-existant --operatingsystem-id
2.
3.

Actual results:

Could not create the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_operatingsystem_id_fk"
  DETAIL:  Key (operatingsystem_id)=(3) is not present in table "operatingsystems".


Expected results:

Should throw an error at an early stage, with a message something like,
"operatingsystem not found by id '3' "



Additional info:

Comment 6 Bryan Kearney 2018-09-04 17:44:09 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.


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