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 1189478 - Unable to create lifecycle-env with cli or UI
Summary: Unable to create lifecycle-env with cli or UI
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: Nightly
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Adam Price
QA Contact: Tazim Kolhar
URL: http://projects.theforeman.org/issues...
Whiteboard:
: 1203660 1215027 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-05 13:14 UTC by Kedar Bidarkar
Modified: 2017-02-23 20:35 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 14:01:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9628 0 None None None 2016-04-22 15:39:08 UTC

Description Kedar Bidarkar 2015-02-05 13:14:10 UTC
Description of problem:

Unable to create lifecycle-environment with cli.

Throws the below error.

[ERROR 2015-02-05 08:12:03 Exception] PGError: ERROR:  missing FROM-clause entry for table "katello_environments"
LINE 1: ...LECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_e...
                                                             ^
: SELECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_environments"."organization_id" = 1 AND "katello_environments"."name" = 'Library'
Could not create environment:
  PGError: ERROR:  missing FROM-clause entry for table "katello_environments"
  LINE 1: ...LECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_e...
                                                               ^
  : SELECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_environments"."organization_id" = 1 AND "katello_environments"."name" = 'Library'
[ERROR 2015-02-05 08:12:03 Exception] 

RestClient::InternalServerError (500 Internal Server Error):
    /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
    /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `transmit'
    /usr/lib/ruby/1.8/net/http.rb:543:in `start'



Version-Release number of selected component (if applicable):
sat6.1 Beta-snap1-compose2

How reproducible:
always

Steps to Reproduce:
1. creation of lifecycle-env using cli
2.
3.

Actual results:
unable to create lifecycle-env using cli

Expected results:
lifecycle-env should get created.

Additional info:

Comment 2 Og Maciel 2015-02-05 15:26:55 UTC
# hammer -u admin -p changeme lifecycle-environment list --organization-id 1
---|---------|------
ID | NAME    | PRIOR
---|---------|------
1  | Library |
---|---------|------

# hammer -v -d -u admin -p changeme lifecycle-environment create --organization-id 1 --name foobar --prior 1
[ INFO 2015-02-05 10:25:41 Init] Initialization of Hammer CLI (0.1.4) has started...
[DEBUG 2015-02-05 10:25:41 Init] Running at ruby 2.0.0-p353
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli.modules.d/gutterball.yml has been loaded
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli.modules.d/import.yml has been loaded
[ INFO 2015-02-05 10:25:41 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[DEBUG 2015-02-05 10:25:41 Connection] Registered: foreman
[DEBUG 2015-02-05 10:25:41 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en"
}
[ INFO 2015-02-05 10:25:41 Modules] Extension module hammer_cli_foreman (0.1.4) loaded
[ INFO 2015-02-05 10:25:41 Modules] Extension module hammer_cli_import (0.10.4) loaded
[ INFO 2015-02-05 10:25:41 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2015-02-05 10:25:41 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2015-02-05 10:25:41 Modules] Extension module hammer_cli_katello (0.0.7) loaded
[DEBUG 2015-02-05 10:25:41 Init] Using locale 'en'
[DEBUG 2015-02-05 10:25:41 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli-0.1.4/locale'
[DEBUG 2015-02-05 10:25:41 Init] 'mo' files for locale domain 'hammer-cli@system' loaded from '/usr/share/locale'
[DEBUG 2015-02-05 10:25:41 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/hammer_cli_foreman-0.1.4/locale'
[DEBUG 2015-02-05 10:25:41 Init] 'mo' files for locale domain 'hammer-cli-foreman@system' loaded from '/usr/share/locale'
[DEBUG 2015-02-05 10:25:41 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/usr/share/gems/gems/hammer_cli_katello-0.0.7/locale'
[ INFO 2015-02-05 10:25:41 HammerCLI::MainCommand] Called with options: {"option_verbose"=>true, "option_debug"=>true, "option_username"=>"admin", "option_password"=>"***"}
[ INFO 2015-02-05 10:25:41 HammerCLIKatello::LifecycleEnvironmentCommand] Called with options: {}
[ INFO 2015-02-05 10:25:41 HammerCLIKatello::LifecycleEnvironmentCommand::CreateCommand] Called with options: {"option_organization_id"=>"1", "option_name"=>"foobar", "option_prior"=>"1"}
[ INFO 2015-02-05 10:25:41 API] GET /katello/api/organizations/1/environments
[DEBUG 2015-02-05 10:25:41 API] Params: {
    "name" => "1"
}
[DEBUG 2015-02-05 10:25:41 API] Headers: {
    :params => {
        "name" => "1"
    }
}
[DEBUG 2015-02-05 10:25:41 API] Response: {
       "total" => 0,
    "subtotal" => 0,
        "page" => 1,
    "per_page" => 66009,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => []
}
[DEBUG 2015-02-05 10:25:41 API] Response headers: {
                   :date => "Thu, 05 Feb 2015 15:25:41 GMT",
                 :server => "Apache/2.4.6 (Red Hat)",
        :foreman_version => "1.8.0-develop",
    :foreman_api_version => "2",
        :apipie_checksum => "a88f7f806896ffd2fd18204026a3f812",
        :x_ua_compatible => "IE=Edge,chrome=1",
          :cache_control => "must-revalidate, private, max-age=0",
           :x_request_id => "9cb0a0bdea70565636c8856519ee4b1c",
              :x_runtime => "0.053240",
           :x_rack_cache => "miss",
           :x_powered_by => "Phusion Passenger 4.0.18",
             :set_cookie => [
        [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTE5MGU1OGI0ZjQ4ZmFmMGFiNGE3YzcwYjUwNzA4OGM2BjsAVEkiC2xvY2FsZQY7AEYiB2Vu--90bdb38c9603cc772b3160b464c80c9c6ec98016; path=/; HttpOnly",
        [1] "request_method=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"
    ],
                   :etag => "\"c75142b6807ab5f910eb3b53d68046f8\"",
                 :status => "200 OK",
             :connection => "close",
      :transfer_encoding => "chunked",
           :content_type => "application/json; charset=utf-8"
}
[ERROR 2015-02-05 10:25:41 Exception] Error: lifecycle_environment not found
Could not create environment:
  Error: lifecycle_environment not found
[ERROR 2015-02-05 10:25:41 Exception]

HammerCLIForeman::ResolverError (lifecycle_environment not found):
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:191:in `pick_result'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:156:in `find_resource'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:139:in `get_id'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:129:in `block (2 levels) in define_id_finders'
    /usr/share/gems/gems/hammer_cli_katello-0.0.7/lib/hammer_cli_katello/lifecycle_environment.rb:10:in `request_params'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/commands.rb:179:in `send_request'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/apipie/command.rb:34:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:68:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:126:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/bin/hammer:108:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

Comment 3 Mike McCune 2015-02-06 05:40:37 UTC
Deleting via the UI results in an error as well:

" undefined method `[]' for nil:NilClass (NoMethodError) /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0/app/lib/actions/katello/environment/destroy.rb:51:in `humanized_input' /opt/rh/ruby193/root/usr/share/gems/gems/foreman-tasks-0.6.12/app/models/foreman_tasks/task/dynflow_task.rb:72:in `get_humanized' /opt/rh/ruby193/root/usr/share/gems/gems/foreman-tasks-0.6.12/app/models/foreman_tasks/task/dynflow_task.rb:52:in `humanized' /opt/rh/ruby193/root/usr/share/gems/gems/foreman-tasks-0.6.12/app/helpers/foreman_tasks/tasks_helper.rb:6:in `format_task_input' /opt/rh/ruby193/root/usr/share/gems/gems/foreman-tasks-0.6.12/app/views/foreman_tasks/tasks/_details.html.erb:103:in `__opt_rh_ruby____root_usr_share_gems_gems_foreman_tasks________app_views_foreman_tasks_tasks__details_html_erb___3634809583189949780_77112100' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/template.rb:145:in `block in render' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:125:in `instrument' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/template.rb:143:in `render' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/partial_renderer.rb:265:in `render_partial' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/partial_renderer.rb:238:in `block in render' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/partial_renderer.rb:237:in `render' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/renderer.rb:41:in `render_partial' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/renderer/renderer.rb:15:in `render' /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_view/helpers/rendering_helper.rb:24:in `render' /opt/rh/ruby193/root/usr/share/gems/gems/haml-3.1.6/lib/haml/helpers/action_view_mods.rb:13:in `render_with_haml' /opt/rh/ruby193/root/usr/share/gems/gems/foreman-tasks-0.6.12/app/views/foreman_tasks/tasks/show.html.erb:79:in `block in __opt_rh_ruby____root_usr_share_gems_gems_foreman_tasks________app_views_foreman_tasks_tasks_show_html_erb___792847889196071634_76070020' /opt/rh/ruby193/root/usr/share/gems/gem"

more info:

https://sat-perf-04.idm.lab.bos.redhat.com/foreman_tasks/tasks/7e065643-bd21-4b90-8962-e648c583bb4d

Comment 4 Og Maciel 2015-02-06 13:55:04 UTC
My previous comment mentioned that the error was due to using an ID for the --prior attribute, but that is incorrect. Even using a name (string) the error persists:

# hammer -u admin -p changeme lifecycle-environment create --name dev12 --prior Library --organization-id 1
Could not create environment:
  PGError: ERROR:  missing FROM-clause entry for table "katello_environments"
  LINE 1: ...LECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_e...
                                                               ^
  : SELECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_environments"."organization_id" = 1 AND "katello_environments"."name" = 'Library'
[root@qe-sat6-rhel7 ~]# hammer -v -d -u admin -p changeme lifecycle-environment create --name dev12 --prior Library --organization-id 1
[ INFO 2015-02-06 08:51:02 Init] Initialization of Hammer CLI (0.1.4) has started...
[DEBUG 2015-02-06 08:51:02 Init] Running at ruby 2.0.0-p353
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli.modules.d/gutterball.yml has been loaded
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli.modules.d/import.yml has been loaded
[ INFO 2015-02-06 08:51:02 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[DEBUG 2015-02-06 08:51:02 Connection] Registered: foreman
[DEBUG 2015-02-06 08:51:02 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en"
}
[ INFO 2015-02-06 08:51:02 Modules] Extension module hammer_cli_foreman (0.1.4) loaded
[ INFO 2015-02-06 08:51:02 Modules] Extension module hammer_cli_import (0.10.6) loaded
[ INFO 2015-02-06 08:51:02 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2015-02-06 08:51:02 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2015-02-06 08:51:02 Modules] Extension module hammer_cli_katello (0.0.7) loaded
[DEBUG 2015-02-06 08:51:02 Init] Using locale 'en'
[DEBUG 2015-02-06 08:51:02 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli-0.1.4/locale'
[DEBUG 2015-02-06 08:51:02 Init] 'mo' files for locale domain 'hammer-cli@system' loaded from '/usr/share/locale'
[DEBUG 2015-02-06 08:51:02 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/hammer_cli_foreman-0.1.4/locale'
[DEBUG 2015-02-06 08:51:02 Init] 'mo' files for locale domain 'hammer-cli-foreman@system' loaded from '/usr/share/locale'
[DEBUG 2015-02-06 08:51:02 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/usr/share/gems/gems/hammer_cli_katello-0.0.7/locale'
[ INFO 2015-02-06 08:51:02 HammerCLI::MainCommand] Called with options: {"option_verbose"=>true, "option_debug"=>true, "option_username"=>"admin", "option_password"=>"***"}
[ INFO 2015-02-06 08:51:02 HammerCLIKatello::LifecycleEnvironmentCommand] Called with options: {}
[ INFO 2015-02-06 08:51:02 HammerCLIKatello::LifecycleEnvironmentCommand::CreateCommand] Called with options: {"option_organization_id"=>"1", "option_name"=>"dev12", "option_prior"=>"Library"}
[ INFO 2015-02-06 08:51:02 API] GET /katello/api/organizations/1/environments
[DEBUG 2015-02-06 08:51:02 API] Params: {
    "name" => "Library"
}
[DEBUG 2015-02-06 08:51:02 API] Headers: {
    :params => {
        "name" => "Library"
    }
}
[DEBUG 2015-02-06 08:51:02 API] 500 Internal Server Error
{
    "displayMessage" => "PGError: ERROR:  missing FROM-clause entry for table \"katello_environments\"\nLINE 1: ...LECT DISTINCT COUNT(*) FROM \"environments\"  WHERE \"katello_e...\n                                                             ^\n: SELECT DISTINCT COUNT(*) FROM \"environments\"  WHERE \"katello_environments\".\"organization_id\" = 1 AND \"katello_environments\".\"name\" = 'Library'",
            "errors" => [
        [0] "PGError: ERROR:  missing FROM-clause entry for table \"katello_environments\"\nLINE 1: ...LECT DISTINCT COUNT(*) FROM \"environments\"  WHERE \"katello_e...\n                                                             ^\n: SELECT DISTINCT COUNT(*) FROM \"environments\"  WHERE \"katello_environments\".\"organization_id\" = 1 AND \"katello_environments\".\"name\" = 'Library'"
    ]
}
[ERROR 2015-02-06 08:51:02 Exception] PGError: ERROR:  missing FROM-clause entry for table "katello_environments"
LINE 1: ...LECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_e...
                                                             ^
: SELECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_environments"."organization_id" = 1 AND "katello_environments"."name" = 'Library'
Could not create environment:
  PGError: ERROR:  missing FROM-clause entry for table "katello_environments"
  LINE 1: ...LECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_e...
                                                               ^
  : SELECT DISTINCT COUNT(*) FROM "environments"  WHERE "katello_environments"."organization_id" = 1 AND "katello_environments"."name" = 'Library'
[ERROR 2015-02-06 08:51:02 Exception]

RestClient::InternalServerError (500 Internal Server Error):
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
    /usr/share/ruby/net/http.rb:852:in `start'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    /usr/share/gems/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get'
    /usr/share/gems/gems/apipie-bindings-0.0.11/lib/apipie_bindings/api.rb:279:in `call_client'
    /usr/share/gems/gems/apipie-bindings-0.0.11/lib/apipie_bindings/api.rb:210:in `http_call'
    /usr/share/gems/gems/apipie-bindings-0.0.11/lib/apipie_bindings/api.rb:160:in `call'
    /usr/share/gems/gems/apipie-bindings-0.0.11/lib/apipie_bindings/resource.rb:14:in `call'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:169:in `resolved_call'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:155:in `find_resource'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:139:in `get_id'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/id_resolver.rb:129:in `block (2 levels) in define_id_finders'
    /usr/share/gems/gems/hammer_cli_katello-0.0.7/lib/hammer_cli_katello/lifecycle_environment.rb:10:in `request_params'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /usr/share/gems/gems/hammer_cli_foreman-0.1.4/lib/hammer_cli_foreman/commands.rb:179:in `send_request'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/apipie/command.rb:34:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4/bin/hammer:108:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

Comment 5 jaudet 2015-02-06 16:31:39 UTC
I believe the root cause of this issue is a malformed SQL query which is executed whenever searching for lifecycle environments by name.

When you attempt to create a new lifecycle environment, you must specify some previous lifecycle environment. The usual way to do this is to provide the name of some previous lifecycle environment. For example, the CLI offers the --prior flag for this purpose:

    hammer -u alice -p hackme lifecycle-environment create --organization-id 7 --prior Library

When a command such as the above is executed, a search is kicked off to find a lifecycle environment with a name of "Library". Unfortuantely, that causes a malformed SQL query to execute, thus triggering an HTTP 500 ISE.

Thus, it *is* possible to create a new lifecycle environment. But you can only do so if you know the ID of the library you want to link to, and if you're willing to use the API. For example, here's some Python code that I've successfully executed:

    from robottelo import entities
    attrs = entities.LifecycleEnvironment(prior=1).create_json()
    entities.LifecycleEnvironment(id=attrs['id']).read_json()

Notice how I'm specifying "prior=1". As a result, the server never needs to search for lifecycle environments. I've already provided an ID.

As an aside, the parameter name "prior" is absolutely terrible. It is an *extremely* common pattern for all ID-based fields to have the suffix _id or _ids. The LifecycleEnvironment.prior field is the only ID-based field I know of which lacks this suffix.

Comment 6 Adam Price 2015-02-23 22:40:33 UTC
i'm unable to reproduce this bug in a development setup running from master.

$ hammer lifecycle-environment create --name new-env --prior Library --organization-id 1                                                                                    
Environment created


$ hammer lifecycle-environment list --organization-id 1
---|---------|--------
ID | NAME    | PRIOR  
---|---------|--------
5  | new-env | Library
1  | Library |        
4  | dev12   | Library
---|---------|--------

Comment 9 Adam Price 2015-03-03 22:12:28 UTC
Created redmine issue http://projects.theforeman.org/issues/9628 from this bug

Comment 10 Adam Price 2015-03-03 22:14:54 UTC
pull-request opened to change documentation: https://github.com/Katello/katello/pull/5072

Comment 11 Eric Helms 2015-03-22 14:48:43 UTC
*** Bug 1203660 has been marked as a duplicate of this bug. ***

Comment 14 Mike McCune 2015-04-24 18:14:52 UTC
*** Bug 1215027 has been marked as a duplicate of this bug. ***

Comment 15 Mike McCune 2015-04-27 15:12:45 UTC
This will fail again with error:

Couldn't find Katello::KTEnvironment with id=Library 

we missed a cherrypick:

https://github.com/Katello/hammer-cli-katello/pull/288

Comment 18 Tazim Kolhar 2015-05-04 08:54:35 UTC
VERIFIED:

# rpm -qa | grep foreman
puppet-foreman_scap_client-0.3.3-8.el7sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.10-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.12.4-1.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.8-1.el7sat.noarch
foreman-libvirt-1.7.2.18-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.12-1.el7sat.noarch
foreman-compute-1.7.2.18-1.el7sat.noarch
foreman-ovirt-1.7.2.18-1.el7sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.12-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.4-1.el7sat.noarch
foreman-debug-1.7.2.18-1.el7sat.noarch
foreman-postgresql-1.7.2.18-1.el7sat.noarch
qe-sat6-rhel71.usersys.redhat.com-foreman-client-1.0-1.noarch
qe-sat6-rhel71.usersys.redhat.com-foreman-proxy-1.0-1.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch
foreman-1.7.2.18-1.el7sat.noarch
foreman-gce-1.7.2.18-1.el7sat.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.10-1.el7sat.noarch
foreman-selinux-1.7.2.13-1.el7sat.noarch
foreman-vmware-1.7.2.18-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.6-1.el7sat.noarch
foreman-proxy-1.7.2.4-1.el7sat.noarch
qe-sat6-rhel71.usersys.redhat.com-foreman-proxy-client-1.0-1.noarch
ruby193-rubygem-foreman-redhat_access-0.1.0-1.el7sat.noarch


steps:
# hammer -u admin -p changeme lifecycle-environment list --organization-id 1
---|---------|------
ID | NAME    | PRIOR
---|---------|------
1  | Library |      
---|---------|------

# hammer -v -d -u admin -p changeme lifecycle-environment create --organization-id 1 --name foobar --prior Library
[ INFO 2015-05-04 04:52:10 Init] Initialization of Hammer CLI (0.1.4.9) has started...
[DEBUG 2015-05-04 04:52:10 Init] Running at ruby 2.0.0-p598
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/gutterball.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/import.yml has been loaded
[ INFO 2015-05-04 04:52:10 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[DEBUG 2015-05-04 04:52:10 Connection] Registered: foreman
[DEBUG 2015-05-04 04:52:10 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en"
}
[ INFO 2015-05-04 04:52:10 Modules] Extension module hammer_cli_foreman (0.1.4.10) loaded
[ INFO 2015-05-04 04:52:10 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.2.6) loaded
[ INFO 2015-05-04 04:52:10 Modules] Extension module hammer_cli_foreman_discovery (0.0.1.8) loaded
[ INFO 2015-05-04 04:52:10 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2015-05-04 04:52:10 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2015-05-04 04:52:10 Modules] Extension module hammer_cli_import (0.10.6.5) loaded
[ INFO 2015-05-04 04:52:10 Modules] Extension module hammer_cli_katello (0.0.7.9) loaded
[DEBUG 2015-05-04 04:52:10 Init] Using locale 'en'
[DEBUG 2015-05-04 04:52:10 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/usr/share/gems/gems/hammer_cli-0.1.4.9/locale'
[DEBUG 2015-05-04 04:52:10 Init] 'mo' files for locale domain 'hammer-cli@system' loaded from '/usr/share/locale'
[DEBUG 2015-05-04 04:52:10 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/usr/share/gems/gems/hammer_cli_foreman-0.1.4.10/locale'
[DEBUG 2015-05-04 04:52:10 Init] 'mo' files for locale domain 'hammer-cli-foreman@system' loaded from '/usr/share/locale'
[DEBUG 2015-05-04 04:52:10 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/usr/share/gems/gems/hammer_cli_katello-0.0.7.9/locale'
[ INFO 2015-05-04 04:52:10 HammerCLI::MainCommand] Called with options: {"option_verbose"=>true, "option_debug"=>true, "option_username"=>"admin", "option_password"=>"***"}
[ INFO 2015-05-04 04:52:10 HammerCLIKatello::LifecycleEnvironmentCommand] Called with options: {}
[ INFO 2015-05-04 04:52:10 HammerCLIKatello::LifecycleEnvironmentCommand::CreateCommand] Called with options: {"option_prior"=>"Library", "option_organization_id"=>"1", "option_name"=>"foobar"}
[ INFO 2015-05-04 04:52:11 API] GET /katello/api/organizations/1/environments
[DEBUG 2015-05-04 04:52:11 API] Params: {
    "name" => "Library"
}
[DEBUG 2015-05-04 04:52:11 API] Headers: {
    :params => {
        "name" => "Library"
    }
}
[DEBUG 2015-05-04 04:52:11 API] Response: {
       "total" => 1,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 23772,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
                      "id" => 1,
                    "name" => "Library",
                   "label" => "Library",
             "description" => nil,
            "organization" => {
                 "name" => "Default Organization",
                "label" => "Default_Organization",
                   "id" => 1
            },
              "created_at" => "2015-04-29T17:11:46Z",
              "updated_at" => "2015-04-29T17:11:46Z",
                 "library" => true,
                   "prior" => nil,
               "successor" => nil,
                  "counts" => {
                      "content_hosts" => 0,
                      "content_views" => 0,
                           "packages" => 22,
                     "puppet_modules" => 0,
                             "errata" => {
                       "security" => 7,
                         "bugfix" => 3,
                    "enhancement" => 7,
                          "total" => 17
                },
                   "yum_repositories" => 1,
                "docker_repositories" => 0,
                           "products" => 1
            },
             "permissions" => {
                                    "view_lifecycle_environments" => true,
                                    "edit_lifecycle_environments" => true,
                                 "destroy_lifecycle_environments" => false,
                "promote_or_remove_content_views_to_environments" => true
            }
        }
    ]
}
[DEBUG 2015-05-04 04:52:11 API] Response headers: {
                   :date => "Mon, 04 May 2015 08:52:11 GMT",
                 :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
        :foreman_version => "1.7.2",
    :foreman_api_version => "2",
        :apipie_checksum => "85179ec311129f67b4c37efdfb780a69",
        :x_ua_compatible => "IE=Edge,chrome=1",
          :cache_control => "must-revalidate, private, max-age=0",
           :x_request_id => "192885c297503069932d358867258dbf",
              :x_runtime => "0.287416",
           :x_rack_cache => "miss",
           :x_powered_by => "Phusion Passenger 4.0.18",
             :set_cookie => [
        [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJThhYjc4ZjIyMTk5ZTA3YjA5YjNkODJlN2ZhZDUxNzAwBjsAVEkiC2xvY2FsZQY7AEYiB2Vu--bc39b26fb585f941528cd29f26e91855bd474361; path=/; HttpOnly"
    ],
                   :etag => "\"90816fcf5fe7ec9b9b6753ce00c9576a\"",
                 :status => "200 OK",
             :connection => "close",
      :transfer_encoding => "chunked",
           :content_type => "application/json; charset=utf-8"
}
[ INFO 2015-05-04 04:52:11 API] POST /katello/api/organizations/1/environments
[DEBUG 2015-05-04 04:52:11 API] Params: {
        "name" => "foobar",
    "prior_id" => 1
}
[DEBUG 2015-05-04 04:52:11 API] Headers: {}
[DEBUG 2015-05-04 04:52:12 API] Response: {
              "id" => 510,
            "name" => "foobar",
           "label" => "foobar",
     "description" => nil,
    "organization" => {
         "name" => "Default Organization",
        "label" => "Default_Organization",
           "id" => 1
    },
      "created_at" => "2015-05-04T08:52:11Z",
      "updated_at" => "2015-05-04T08:52:11Z",
         "library" => false,
           "prior" => {
        "name" => "Library",
          "id" => 1
    },
       "successor" => nil,
          "counts" => {
        "content_hosts" => 0,
        "content_views" => 0
    },
     "permissions" => {
                            "view_lifecycle_environments" => true,
                            "edit_lifecycle_environments" => true,
                         "destroy_lifecycle_environments" => true,
        "promote_or_remove_content_views_to_environments" => true
    }
}
[DEBUG 2015-05-04 04:52:12 API] Response headers: {
                   :date => "Mon, 04 May 2015 08:52:11 GMT",
                 :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
        :foreman_version => "1.7.2",
    :foreman_api_version => "2",
        :apipie_checksum => "85179ec311129f67b4c37efdfb780a69",
        :x_ua_compatible => "IE=Edge,chrome=1",
          :cache_control => "max-age=0, private, must-revalidate",
           :x_request_id => "ca7a50a78a118adba16333888a7e52c6",
              :x_runtime => "0.908385",
           :x_rack_cache => "invalidate, pass",
           :x_powered_by => "Phusion Passenger 4.0.18",
             :set_cookie => [
        [0] "_session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTY2YzU2ODMwOGQyZDAwOTljNWViYWU4OWQ1M2VkZTFkBjsAVEkiC2xvY2FsZQY7AEYiB2Vu--130fb1e1c82bd2dae93ff90ccf7458da6d6c117f; path=/; HttpOnly"
    ],
                   :etag => "\"e209a28e30013b90db9221f7e92bebd0\"",
                 :status => "200 OK",
             :connection => "close",
      :transfer_encoding => "chunked",
           :content_type => "application/json; charset=utf-8"
}
Environment created

Comment 19 Bryan Kearney 2015-08-11 13:26:31 UTC
This bug is slated to be released with Satellite 6.1.

Comment 20 Bryan Kearney 2015-08-12 14:01:01 UTC
This bug was fixed in version 6.1.1 of Satellite which was released on 12 August, 2015.


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