Bug #30205
closedRequest to /api/statuses returns 500 ISE when a smart proxy has "logs" feature disabled
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:
Updated by The Foreman Bot over 4 years ago
- Status changed from New to Ready For Testing
- Assignee set to Pavel Moravec
- Pull request https://github.com/theforeman/foreman/pull/7770 added
Updated by Pavel Moravec over 4 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset 85dd7843815ca56bae9b4ac2d0043ee128f5e6ec.
Updated by The Foreman Bot over 4 years ago
- Pull request https://github.com/theforeman/foreman/pull/7975 added