Project

General

Profile

Bug #30205

Request to /api/statuses returns 500 ISE when a smart proxy has "logs" feature disabled

Added by Pavel Moravec 5 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
-
Difficulty:
easy
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

(cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1850440)

Description of problem:
Disabling "logs" feature in internal or external smart proxy, 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):
any / current upstream

How reproducible:
100%

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

3. Check statuses API call on foreman:

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:

Associated revisions

Revision 85dd7843 (diff)
Added by Pavel Moravec 5 months ago

Fixes #30205 - smart proxies statuses with logs feature disabled

Grab failed_features in a more specific way, not relying on "logs"
feature that might be disabled.

Signed-off-by: Pavel Moravec <>

History

#1 Updated by The Foreman Bot 5 months ago

  • Assignee set to Pavel Moravec
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/7770 added

#2 Updated by The Foreman Bot 5 months ago

  • Fixed in Releases 2.2.0 added

#3 Updated by Pavel Moravec 5 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by The Foreman Bot 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/7975 added

Also available in: Atom PDF