Bug 1354568

Summary: creating a hostgroup with invalid id option should raise proper error instead of foreign key constraint error
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: APIAssignee: Dominik Hlavac Duran <dhlavacd>
Status: CLOSED WONTFIX QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bkearney, mhulan, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-04 17:42:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1398392    
Bug Blocks: 1484102    

Description Sachin Ghai 2016-07-11 15:20:43 UTC
Description of problem:
Creating a hostgroup with invalid subnet id raises:

~]# hammer -u admin -p changeme hostgroup create --name test123512 --organizations='Default Organization' --location-ids 1 --puppet-proxy-id 1   --puppet-ca-proxy-id 1 --root-pass redhat123 --subnet-id 1 --domain-id 1
Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_subnet_id_fk"
  DETAIL:  Key (subnet_id)=(1) is not present in table "subnets".

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

How reproducible:


Steps to Reproduce:
1. create hostgroup with invalid subnet-id
2.
3.

Actual results:


Expected results:
user should get an error: subnet not found


Additional info:

Comment 2 Sachin Ghai 2016-07-12 08:12:46 UTC
this issue appears with all 'id' options of hostgroup like:

invalid arch-id:
===============
 ~]# hammer -u admin -p changeme hostgroup create --name test1234455 --architecture-id 45
Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_architecture_id_fk"
  DETAIL:  Key (architecture_id)=(45) is not present in table "architectures".


invalid domain-id:
==================~]# hammer -u admin -p changeme hostgroup create --name test1234455 --domain-id 45
Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_domain_id_fk"
  DETAIL:  Key (domain_id)=(45) is not present in table "domains".

invalid puppet-proxy-id:
=======================
~]# hammer -u admin -p changeme hostgroup create --name test1234455 --puppet-proxy-id 45
Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_puppet_proxy_id_fk"
  DETAIL:  Key (puppet_proxy_id)=(45) is not present in table "smart_proxies".



user should get error: Couldn't find domain 'id' OR could not find architecture 'id'

Comment 3 Bryan Kearney 2016-12-20 11:09:24 UTC
Upstream bug assigned to szadok

Comment 4 Bryan Kearney 2016-12-20 11:09:27 UTC
Upstream bug assigned to szadok

Comment 5 Bryan Kearney 2016-12-20 17:09:36 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17525 has been resolved.

Comment 6 Stanislav Tkachenko 2017-06-14 08:27:38 UTC
Failed on Satellite 6.3 Snap 2.0:
* foreman-1.15.0-1.el7sat.noarch
* satellite-6.3.0-15.0.beta.el7sat.noarch
* katello-3.4.0-3.el7sat.noarch

Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_subnet_id_fk"
  DETAIL:  Key (subnet_id)=(5278) is not present in table "subnets".

Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_domain_id_fk"
  DETAIL:  Key (domain_id)=(9981) is not present in table "domains".

Could not create the hostgroup:
  ERROR:  insert or update on table "hostgroups" violates foreign key constraint "hostgroups_architecture_id_fk"
  DETAIL:  Key (architecture_id)=(3990) is not present in table "architectures".

Comment 7 Satellite Program 2017-06-30 18:10:49 UTC
Upstream bug assigned to szadok

Comment 9 Satellite Program 2017-07-03 08:10:51 UTC
Upstream bug assigned to szadok

Comment 10 Satellite Program 2017-08-09 12:10:42 UTC
Upstream bug assigned to dhlavacd

Comment 11 Satellite Program 2017-08-09 12:10:45 UTC
Upstream bug assigned to dhlavacd

Comment 14 Marek Hulan 2017-09-11 11:41:39 UTC
Created redmine issue http://projects.theforeman.org/issues/20888 from this bug

Comment 15 Bryan Kearney 2018-09-04 17:42:38 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.