Project

General

Profile

Actions

Bug #22693

closed

hammer can't create user-group with more than 20 roles

Added by Lukas Kallies about 6 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Category:
Users and roles
Target version:
-
Difficulty:
Triaged:
No
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

hammer can't create a user-group wiht more than 20 roles. It is possible to create a user-group with more than 20 roles in the UI, though.

How to reproduce

Create roles:

for i in {1..23}; do hammer role create --name ${i}; done
hammer user-group create --name xux --admin true --roles '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21'

Expected Output

User group [xux] created

Adding only 20 roles works:

hammer -c katello.yaml user-group create --name xux --admin true --roles '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'
User group [xux] created

Output

Could not create the user group:
  Error: one of roles not found

Debug Output

[ INFO 2018-02-26 13:49:09 Init] Initialization of Hammer CLI (0.11.0) has started...
[DEBUG 2018-02-26 13:49:09 Init] Running at ruby 2.4.0-p0
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2018-02-26 13:49:09 Init] Configuration from the file /home/vagrant/katello.yaml has been loaded
[DEBUG 2018-02-26 13:49:09 SSLoptions] SSL options: {
    :ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt",
     :verify_ssl => true
}
[DEBUG 2018-02-26 13:49:09 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en" 
}
[DEBUG 2018-02-26 13:49:09 API] Follow redirects: never
[DEBUG 2018-02-26 13:49:09 Connection] Registered: foreman
[ INFO 2018-02-26 13:49:09 Modules] Extension module hammer_cli_foreman (0.11.0) loaded
[ INFO 2018-02-26 13:49:09 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3) loaded
[ INFO 2018-02-26 13:49:09 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2018-02-26 13:49:09 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2018-02-26 13:49:09 Modules] Extension module hammer_cli_katello (0.11.5.1) loaded
[DEBUG 2018-02-26 13:49:09 Init] Using locale 'en'
[DEBUG 2018-02-26 13:49:09 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/locale'
[DEBUG 2018-02-26 13:49:09 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/locale'
[DEBUG 2018-02-26 13:49:09 Init] 'mo' files for locale domain 'hammer_cli_foreman_docker' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_docker-0.0.4/locale'
[DEBUG 2018-02-26 13:49:09 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.11.5.1/locale'
[ INFO 2018-02-26 13:49:09 HammerCLI::MainCommand] Called with options: {"option_debug"=>true, "option_config"=>"katello.yaml"}
[ INFO 2018-02-26 13:49:09 HammerCLIForeman::Usergroup] Called with options: {}
[ INFO 2018-02-26 13:49:09 HammerCLIForeman::Usergroup::CreateCommand] Called with options: {"option_role_names"=>["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21"], "option_name"=>"xux", "option_admin"=>true}
[ INFO 2018-02-26 13:49:09 API] Server: https://centos7-katello-3-6.lkallies-puzzle.example.com
[ INFO 2018-02-26 13:49:09 API] GET /api/roles
[DEBUG 2018-02-26 13:49:09 API] Params: {
    :search => "name = \"1\" or name = \"2\" or name = \"3\" or name = \"4\" or name = \"5\" or name = \"6\" or name = \"7\" or name = \"8\" or name = \"9\" or name = \"10\" or name = \"11\" or name = \"12\" or name = \"13\" or name = \"14\" or name = \"15\" or name = \"16\" or name = \"17\" or name = \"18\" or name = \"19\" or name = \"20\" or name = \"21\"" 
}
[DEBUG 2018-02-26 13:49:09 API] Headers: {
    :params => {
        :search => "name = \"1\" or name = \"2\" or name = \"3\" or name = \"4\" or name = \"5\" or name = \"6\" or name = \"7\" or name = \"8\" or name = \"9\" or name = \"10\" or name = \"11\" or name = \"12\" or name = \"13\" or name = \"14\" or name = \"15\" or name = \"16\" or name = \"17\" or name = \"18\" or name = \"19\" or name = \"20\" or name = \"21\"" 
    }
}
[DEBUG 2018-02-26 13:49:09 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-02-26 13:49:09 API] Response: {
       "total" => 35,
    "subtotal" => 21,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"1\" or name = \"2\" or name = \"3\" or name = \"4\" or name = \"5\" or name = \"6\" or name = \"7\" or name = \"8\" or name = \"9\" or name = \"10\" or name = \"11\" or name = \"12\" or name = \"13\" or name = \"14\" or name = \"15\" or name = \"16\" or name = \"17\" or name = \"18\" or name = \"19\" or name = \"20\" or name = \"21\"",
        "sort" => {
           "by" => "name",
        "order" => "ASC" 
    },
     "results" => [
        [ 0] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "1",
                        "id" => 13,
               "description" => nil,
                    "origin" => nil
        },
        [ 1] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "10",
                        "id" => 22,
               "description" => nil,
                    "origin" => nil
        },
        [ 2] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "11",
                        "id" => 23,
               "description" => nil,
                    "origin" => nil
        },
        [ 3] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "12",
                        "id" => 24,
               "description" => nil,
                    "origin" => nil
        },
        [ 4] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "13",
                        "id" => 25,
               "description" => nil,
                    "origin" => nil
        },
        [ 5] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "14",
                        "id" => 26,
               "description" => nil,
                    "origin" => nil
        },
        [ 6] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "15",
                        "id" => 27,
               "description" => nil,
                    "origin" => nil
        },
        [ 7] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "16",
                        "id" => 28,
               "description" => nil,
                    "origin" => nil
        },
        [ 8] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "17",
                        "id" => 29,
               "description" => nil,
                    "origin" => nil
        },
        [ 9] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "18",
                        "id" => 30,
               "description" => nil,
                    "origin" => nil
        },
        [10] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "19",
                        "id" => 31,
               "description" => nil,
                    "origin" => nil
        },
        [11] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "2",
                        "id" => 14,
               "description" => nil,
                    "origin" => nil
        },
        [12] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "20",
                        "id" => 32,
               "description" => nil,
                    "origin" => nil
        },
        [13] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "21",
                        "id" => 33,
               "description" => nil,
                    "origin" => nil
        },
        [14] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "3",
                        "id" => 15,
               "description" => nil,
                    "origin" => nil
        },
        [15] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "4",
                        "id" => 16,
               "description" => nil,
                    "origin" => nil
        },
        [16] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "5",
                        "id" => 17,
               "description" => nil,
                    "origin" => nil
        },
        [17] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "6",
                        "id" => 18,
               "description" => nil,
                    "origin" => nil
        },
        [18] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "7",
                        "id" => 19,
               "description" => nil,
                    "origin" => nil
        },
        [19] {
                   "builtin" => 0,
            "cloned_from_id" => nil,
                      "name" => "8",
                        "id" => 20,
               "description" => nil,
                    "origin" => nil
        }
    ]
}
[DEBUG 2018-02-26 13:49:09 API] Response headers: {
                                 :date => "Mon, 26 Feb 2018 13:49:09 GMT",
                               :server => "Apache/2.4.6 (CentOS)",
                      :foreman_version => "1.17.0-RC1",
                  :foreman_api_version => "2",
                      :apipie_checksum => "1887f750ded6566752ed57aa035ea1f6",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "e9cd96f3-1ca0-43aa-ba30-ef4cc60e99de",
                            :x_runtime => "0.051775",
              :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data: *.gravatar.com; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
            :strict_transport_security => "max-age=631139040; includeSubdomains",
               :x_content_type_options => "nosniff",
                   :x_download_options => "noopen",
                      :x_frame_options => "sameorigin",
    :x_permitted_cross_domain_policies => "none",
                     :x_xss_protection => "1; mode=block",
                         :x_powered_by => "Phusion Passenger 4.0.53",
                           :set_cookie => [
        [0] "_session_id=c0d3dbd63ca34e0444fbb5fa4d542161; path=/; secure; HttpOnly" 
    ],
                                 :etag => "W/\"a57e2c3b3f45ce2ed661b044e7534085-gzip\"",
                               :status => "200 OK",
                                 :vary => "Accept-Encoding",
                     :content_encoding => "gzip",
                       :content_length => "348",
                         :content_type => "application/json; charset=utf-8" 
}
[DEBUG 2018-02-26 13:49:09 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_general_exception
[ERROR 2018-02-26 13:49:09 Exception] Error: one of roles not found
Could not create the user group:
  Error: one of roles not found
[ERROR 2018-02-26 13:49:09 Exception] 

HammerCLIForeman::ResolverError (one of roles not found):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/id_resolver.rb:159:in `find_resources'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/id_resolver.rb:150:in `get_ids'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/id_resolver.rb:137:in `block (2 levels) in define_id_finders'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:142:in `get_resource_ids'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:208:in `block in customized_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:205:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:205:in `customized_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:220:in `request_params'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.11.0/lib/hammer_cli_foreman/commands.rb:166:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/apipie/command.rb:34:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/bin/hammer:147:in `<top (required)>'
    /usr/bin/hammer:22:in `load'
    /usr/bin/hammer:22:in `<main>'

hammer version

[vagrant@centos7-katello-3-6 ~]$ rpm -qa tfm-rubygem-hammer_cli\*
tfm-rubygem-hammer_cli_foreman_bootdisk-0.1.3-6.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.11.0-2.el7.noarch
tfm-rubygem-hammer_cli_katello-0.11.5.1-1.el7.noarch
tfm-rubygem-hammer_cli-0.11.0-2.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.12-2.fm1_17.el7.noarch
tfm-rubygem-hammer_cli_foreman_docker-0.0.4-3.el7.noarch

Related issues 1 (0 open1 closed)

Is duplicate of Hammer CLI - Bug #24717: hammer hostgroup create fails due to pagination when the number of supplied puppet classes exceeds entries_per_pageClosedOleh FedorenkoActions
Actions #1

Updated by Tomáš Strachota about 6 years ago

Thank you for the thorough report. This is caused by using default pagination value for the id lookup, when the names are translated to ids.

Since you're using ids anyway, you could use --role-ids as a workaround.

Actions #2

Updated by Martin Bacovsky about 6 years ago

Other workaround till this is fixed in hammer is to set pagination on the server to some higher value (Settings > General > Entries per page)

Actions #3

Updated by Lukas Kallies about 6 years ago

Tomáš Strachota wrote:

Thank you for the thorough report. This is caused by using default pagination value for the id lookup, when the names are translated to ids.

Thanks for the clarification regarding pagination!

Since you're using ids anyway, you could use --role-ids as a workaround.

Acutally I'm not using IDs "in the wild", I've used them for reproducing the issue with Katello. Originally I discovered the issue when configuring Red Hat Satellite 6.3. 6.3 provides 23 default roles, 6.2 provided 19.

Actions #4

Updated by Lukas Kallies about 6 years ago

Martin Bacovsky wrote:

Other workaround till this is fixed in hammer is to set pagination on the server to some higher value (Settings > General > Entries per page)

Thanks, this workaround does the trick for now (obviously it works also with Satellite).

Actions #5

Updated by Martin Bacovsky almost 5 years ago

  • Is duplicate of Bug #24717: hammer hostgroup create fails due to pagination when the number of supplied puppet classes exceeds entries_per_page added
Actions #6

Updated by Oleh Fedorenko almost 5 years ago

  • Status changed from New to Closed
Actions #7

Updated by Martin Bacovsky almost 5 years ago

  • Bugzilla link set to 1550487
Actions #8

Updated by Martin Bacovsky almost 5 years ago

  • Assignee set to Oleh Fedorenko
Actions

Also available in: Atom PDF