Hide Forgot
Description of problem: If you specify non-existent content source id for hammer host/hostgroup create/update command, SQL error is shown instead of validation message. Version-Release number of selected component (if applicable): Satellite 6.3.0 Snap 14 How reproducible: Always Steps to Reproduce: 1. Execute host/hostgroup create/update command with --content-source-id set to some nonexistent id: hammer host create --medium-id="169" --ip="###.###.##.###" --location-id="2" --operatingsystem-id="3" --lifecycle-environment-id="593" --domain-id="1" --partition-table-id="87" --content-source-id="61340" --mac="40:8f:bf:b6:ca:7a" --content-view-id="618" --architecture-id="1" --organization="RshekR" --name="mYXwuGUHRd" --root-password="test" 2. 3. Actual results: [ERROR 2017-09-05 09:04:15 API] 500 Internal Server Error [ERROR 2017-09-05 09:04:15 Exception] ERROR: insert or update on table "katello_content_facets" violates foreign key constraint "katello_content_facets_content_source_id_fk" DETAIL: Key (content_source_id)=(61340) is not present in table "smart_proxies". Could not create the host: ERROR: insert or update on table "katello_content_facets" violates foreign key constraint "katello_content_facets_content_source_id_fk" DETAIL: Key (content_source_id)=(61340) is not present in table "smart_proxies". [ERROR 2017-09-05 09:04:15 Exception] RestClient::InternalServerError (500 Internal Server Error): /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/api.rb:352:in `block in rest_client_call_block' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:493:in `process_result' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:421:in `block in transmit' /opt/rh/rh-ruby23/root/usr/share/ruby/net/http.rb:853:in `start' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:413:in `transmit' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/resource.rb:67:in `post' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/api.rb:324:in `call_client' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/api.rb:240:in `http_call' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/api.rb:190:in `call_action' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/api.rb:185:in `call' /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.0/lib/apipie_bindings/resource.rb:21:in `call' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/apipie/command.rb:43:in `send_request' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/commands.rb:166:in `send_request' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/apipie/command.rb:34:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/abstract.rb:29:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/abstract.rb:29:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/abstract.rb:29:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/bin/hammer:147:in `<top (required)>' /usr/bin/hammer:23:in `load' /usr/bin/hammer:23:in `<main>' Expected results: Some kind of validation message explaining that content source was not found by provided id should be shown. Additional info:
Created redmine issue http://projects.theforeman.org/issues/21689 from this bug
This would require a change in Foreman and across Katello potentially. It exists whenever a model has relationships to other models via foreign keys.
snap 23, not 63
There are two error messages displayed: "Content Source not found" (when --content-source is passed) or "Content source with given ID not found" (when --content-source-id is passed). These are consistent with what Jan saw before fix had to be reverted. The same error messages are displayed for host create/update and hostgroup create/update. #v+ # hammer host create --name bz1488475-host-create --organization "Default Organization" --location "Default Location" --medium-id="1" --ip="1.2.3.4" --operatingsystem-id="1" --lifecycle-environment-id="1" --domain-id="1" --partition-table-id="1" --mac="40:8f:bf:b6:ca:7a" --content-view-id=1 --architecture-id=1 --root-password="testtesttest" --content-source "This does not exist" Could not create the host: Error: Content Source not found. # hammer host create --name bz1488475-host-create --organization "Default Organization" --location "Default Location" --ip="1.2.3.4" --operatingsystem-id="1" --lifecycle-environment-id="1" --domain-id="2" --partition-table-id="1" --mac="40:8f:bf:b6:ca:7a" --content-view-id=1 --architecture-id=1 --hostgroup-id 1 --root-password="testtesttest" --content-source-id=9999 Could not create the host: Content source with given ID not found # hammer host update --id 3 --content-source "This does not exist" Could not update the host: Error: Content Source not found. # hammer host update --id 3 --content-source-id=9999 Could not update the host: Content source with given ID not found # hammer hostgroup create --name bz1488475-hostgroup-create --content-source "This does not exist" Could not create the hostgroup: Error: Content Source not found. # hammer hostgroup create --name bz1488475-hostgroup-create --content-source-id 9999 Could not create the hostgroup: Content source with given ID not found # hammer hostgroup update --id 2 --content-source "This does not exist" Could not update the hostgroup: Error: Content Source not found. # hammer hostgroup update --id 2 --content-source-id 9999 Could not update the hostgroup: Content source with given ID not found #v- Version: Satellite 6.5 snap 18 tfm-rubygem-katello-3.10.0.24-1.el7sat.noarch foreman-1.20.1.10-1.el7sat.noarch pulp-server-2.18.0-0.1.rc.el7sat.noarch satellite-6.5.0-6.beta.el7sat.noarch tfm-rubygem-hammer_cli-0.15.1.1-1.el7sat.noarch tfm-rubygem-hammer_cli_csv-2.3.1-3.el7sat.noarch tfm-rubygem-hammer_cli_foreman-0.15.1-1.el7sat.noarch tfm-rubygem-hammer_cli_foreman_admin-0.0.8-3.el7sat.noarch tfm-rubygem-hammer_cli_foreman_ansible-0.1.1-3.el7sat.noarch tfm-rubygem-hammer_cli_foreman_bootdisk-0.1.3.3-5.el7sat.noarch tfm-rubygem-hammer_cli_foreman_discovery-1.0.0-3.el7sat.noarch tfm-rubygem-hammer_cli_foreman_docker-0.0.6.1-1.el7sat.noarch tfm-rubygem-hammer_cli_foreman_openscap-0.1.6-2.el7sat.noarch tfm-rubygem-hammer_cli_foreman_remote_execution-0.1.0-2.el7sat.noarch tfm-rubygem-hammer_cli_foreman_tasks-0.0.13-1.el7sat.noarch tfm-rubygem-hammer_cli_foreman_templates-0.1.2-1.el7sat.noarch tfm-rubygem-hammer_cli_foreman_virt_who_configure-0.0.3-3.el7sat.noarch tfm-rubygem-hammer_cli_katello-0.16.0.9-1.el7sat.noarch
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/RHSA-2019:1222