Project

General

Profile

Actions

Bug #37953

open

refresh_facts on any of discovered hosts is failing with 500 error

Added by Konstantin Orekhov 18 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Discovery plugin
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

After migrating to Foreman 3.12.0 on Ubuntu 22.04 (foreman_discovery plugin 24.0.2), refresh_facts action on any of discovered hosts returns this error:

ERF50-7522 [Foreman::WrappedException]: Failed to refresh facts for mac<mac> with error ERF50-0929 [Foreman::WrappedException]: Could not get facts from proxy https://&lt;ip&gt;:8443: undefined method `escape' for URI:Module ([NoMethodError]: undefined method `escape' for URI:Module) ([Foreman::WrappedException]: ERF50-0929 [Foreman::WrappedException]: Could not get facts from proxy https://&lt;ip&gt;:8443: undefined method `escape' for URI:Module ([NoMethodError]: undefined method `escape' for URI:Module))

API call also fails in similar way:
$ curl -kSs -H 'Content-type:application/json' -u korekhov:$PASS -X PUT https://&lt;foreman&gt;/api/v2/discovered_hosts/mac&lt;mac&gt;/refresh_facts -d '' | jq '.' {
"message": "ERF50-0929 [Foreman::WrappedException]: Could not get facts from proxy https://&lt;ip&gt;:8443: undefined method `escape' for URI:Module ([NoMethodError]: undefined method `escape' for URI:Module)"
}

New hosts themselves can register just fine though.

The same happens on Foreman 3.11.2 on Ubuntu 22.04 as well, but the same version of Foreman on ubuntu 20.04 is fine, so definitely ruby3 related, which has URI.(un)escape methods removed.

I see that method appears in just 2 places:
/usr/share/foreman/vendor/ruby/3.0.0/gems/foreman_discovery-24.0.2/app/services/foreman_discovery/node_api/node_resource.rb
and
/usr/share/foreman/vendor/ruby/3.0.0/gems/css_parser-1.19.0/lib/css_parser/parser.rb

I have not touched css_parser/parser.rb, but tried updating node_resource.rb with this patch:

--- /usr/share/foreman/vendor/ruby/3.0.0/gems/foreman_discovery-24.0.2/app/services/foreman_discovery/node_api/node_resource.rb-orig 2024-10-25 11:31:00.626019006 0700
++ /usr/share/foreman/vendor/ruby/3.0.0/gems/foreman_discovery-24.0.2/app/services/foreman_discovery/node_api/node_resource.rb 2024-10-25 11:31:19.117638001 -0700
@ -82,7 +82,7 @
def get(payload = {}, path = nil)
logger.debug("Image API GET #{url} (path=#{path}, payload=#{payload})")
if path
resource[URI.escape(path)].get payload
resource[URI.encode_www_form_component(path)].get payload
else
resource.get payload
end

which seems to help as both UI and API calls are not throwing those 500 errors anymore, but just not 100% if this is correct fix, so wanted to report this issue for proper devs to double-check and commit a proper fix.

Thanks!

No data to display

Actions

Also available in: Atom PDF