Nightly Breakage: Need Help with Foreman API, Admin user

All,

I need a bit of help here trying to understand if a breakage was introduced to Foreman in the past 1-2 months. Our pipelines have been largely broken with the shift over to Rails 5.1 and Ruby 2.4 so this breakage could have been introduced over the course of these months.

What I am currently seeing is that with organizations and locations enabled, when puppet creates a host that host ends up created with no organization (as expected). However, when hammer attempts to search for that host’s info as the admin user, no data is returned. I can replicate this with an API call directly as well.

curl -k https://$(hostname)//api/hosts?search=name+%3D+%22centos7-katello-bats-ci.woodford.example.com%22

If I go into the UI, as the admin user, I can see the host just fine. This is blocking a number of nightly tests so any help figuring this out or pointing me in the right direction would be greatly appreciated.

Eric

@Marek_Hulan - this sound like it may be related to recent changes in taxonomy scoping?

http://projects.theforeman.org/issues/22305

1 Like

Thanks Tom for the link. Note that particular issue is separate from the threads issue. There are two fixes that need to be figured out. One for that Redmine issue and one for the thread topic.

This does not sound like the recent org/loc changes issue, we didn’t change the behavior for admins. Do you see the host if you omit searching?

If I go to /api/v2/hosts/1 I do see the host.

If I go to api/hosts?search=name+%3D+"centos7-katello-bats-ci.woodford.example.com" I do see the host. Apparently, I had tried to curl that earlier and it had not put the hostname in quotes which fails the query (which does seem odd).

Via hammer:

[root@centos7-katello-bats-ci katello-installer-base]# hammer host info --id 1
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
Resource host not found by id '1'
[root@centos7-katello-bats-ci katello-installer-base]# hammer host list
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
---|------|------------------|------------|----|-----|--------------|----------------------
ID | NAME | OPERATING SYSTEM | HOST GROUP | IP | MAC | CONTENT VIEW | LIFECYCLE ENVIRONMENT
---|------|------------------|------------|----|-----|--------------|----------------------
[root@centos7-katello-bats-ci katello-installer-base]# 

So this does make it seem like this may be more of a hammer issue.

The hammer version used is upstream/master?
Can I have output of hammer -d host info --id 1? I would expect it to translate to the API call you’ve used (/api/v2/hosts/1). Last week a hammer PR was merged that could influence this so I’d love to help to investigate.

Seems a new error has popped up that is occurring before the previous error output and preventing me from posting it:

[DEBUG 2018-01-21 21:25:27 Exception] Using exception handler HammerCLI::ExceptionHandler#handle_general_exception
[ERROR 2018-01-21 21:25:27 Exception] Error: wrong number of arguments (given 5, expected 4)
Error: wrong number of arguments (given 5, expected 4)
[ERROR 2018-01-21 21:25:27 Exception] 

ArgumentError (wrong number of arguments (given 5, expected 4)):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.11.0/lib/hammer_cli/subcommand.rb:65:in `lazy_subcommand'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.pre.develop/lib/hammer_cli_foreman/smart_class_parameter.rb:163:in `<class:SmartClassParameter>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.pre.develop/lib/hammer_cli_foreman/smart_class_parameter.rb:40:in `<module:HammerCLIForeman>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.pre.develop/lib/hammer_cli_foreman/smart_class_parameter.rb:1:in `<top (required)>'

One thing I do recall from before was that hitting the API directly vs hammer would be slightly different in the production.log:

API

2018-01-21 21:27:51 fc38103f [app] [I] Started GET "/api/hosts/1" for 192.168.121.1 at 2018-01-21 21:27:51 +0000
2018-01-21 21:27:51 fc38103f [app] [I] Processing by Api::V2::HostsController#show as JSON
2018-01-21 21:27:51 fc38103f [app] [I]   Parameters: {"apiv"=>"v2", "id"=>"1"}

Hammer:

2018-01-21 21:30:18 fba31707 [app] [I] Started GET "/api/hosts/1" for 127.0.0.1 at 2018-01-21 21:30:18 +0000
2018-01-21 21:30:18 fba31707 [app] [I] Processing by Api::V2::HostsController#show as JSON
2018-01-21 21:30:18 fba31707 [app] [I]   Parameters: {"apiv"=>"v2", "id"=>"1", "host"=>{}}

I believe this new error will be fixed in this change.

Current evidence suggests this is a packaging issue with out dated nightly hammer packages. I am working on re-building these with the new SCL in mind and re-testing. I will report back here on my findings.

I finally tracked down the issue. This is summarized in the PR I opened so I won’t repeat myself here: