Bug 1850440

Summary: "hammer status" returns 500 ISE when a Capsule or Satellite has foreman-proxy "logs" feature disabled
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: APIAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Petr Pochop <ppochop>
Severity: medium Docs Contact:
Priority: low    
Version: 6.7.0CC: apatel, egolov, fiezzi, gtalreja, ktordeur, mtenheuv, ppochop
Target Milestone: 6.9.0Keywords: Patch, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1919430 (view as bug list) Environment:
Last Closed: 2021-04-21 13:14:56 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:

Description Pavel Moravec 2020-06-24 10:20:29 UTC
Description of problem:
Disabling "logs" feature in foreman-proxy of Satellite or a Capsule, API request:

/api/statuses

returns 500 error.

The reason is evident from source code:

https://github.com/theforeman/foreman/blob/develop/app/services/ping.rb#L66 :

    def statuses_smart_proxies
      results = []
      SmartProxy.all.includes(:features).map do |proxy|
        start = Time.now
        begin
          version = proxy.statuses[:version].version['version']
          features = proxy.statuses[:version].version['modules']
          failed_features = proxy.statuses[:logs].logs.failed_modules
..

The proxy without logs feature has proxy.statuses without :logs :-/

The line should be like:

          failed_features = (proxy.statuses[:logs].nil? ? {} : proxy.statuses[:logs].logs.failed_modules)


Version-Release number of selected component (if applicable):
Sat6.7


How reproducible:
100%


Steps to Reproduce:
1. Have an external Capsule
2. On the Capsule, disable "logs" feature:
satellite-installer --scenario=capsule --foreman-proxy-logs=false

3. Check statuses API call on Satellite:

curl -L -u admin:mysecret007 http://$(hostname -f)/api/statuses


Actual results:
{
  "error": {"message":"Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs."}
}


Expected results:
{"results":{ ... (some usual output)


Additional info:

Comment 1 Bryan Kearney 2020-06-24 16:05:17 UTC
Upstream bug assigned to pmoravec

Comment 2 Bryan Kearney 2020-06-24 16:05:19 UTC
Upstream bug assigned to pmoravec

Comment 4 Pavel Moravec 2020-06-25 11:36:08 UTC
The foreman-proxy "logs" feature was added in 6.4-ish release. Any newer Satellite deployment (not upgraded from that version) should have the feature enabled by default and work well.

BUT any Satellite upgraded from 6.4ish version will have the feature _disabled_ by default, causing "hammer status" (that calls the API request) to fail - by default..

Comment 5 Bryan Kearney 2020-07-05 16:05:08 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30205 has been resolved.

Comment 6 Brad Buckingham 2020-11-13 19:27:59 UTC
Fix is in Satellite 6.9 SNAP 1 with foreman-2.3.0-0.7.rc1.el7sat.noarch

Comment 8 Petr Pochop 2021-03-10 12:35:56 UTC
Verified
On Sat 6.9 snap 15.0

Disabled logging on internal and external capsules. Either way didn't cause any problems, I could access the api and get the status, this time without the "logs" feature listed, as expected.

Comment 11 errata-xmlrpc 2021-04-21 13:14:56 UTC
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 (Moderate: Satellite 6.9 Release), 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-2021:1313