Bug 1729843 - Insights Remediation playbook fails with error "Failed to create job. Ensure your systems are registered in Foreman" when system hostname has uppercase characters
Summary: Insights Remediation playbook fails with error "Failed to create job. Ensure ...
Status: NEW
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Ansible
Version: 6.4
Hardware: All
OS: All
medium vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Lukas Pramuk
Depends On:
TreeView+ depends on / blocked
Reported: 2019-07-15 06:03 UTC by roarora
Modified: 2020-02-12 04:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Target Upstream Version:

Attachments (Terms of Use)

Description roarora 2019-07-15 06:03:24 UTC
Description of problem:

This bug is when system registered to satellite has Uppercase characters like CLIENT.example.com. Satellite converts the hostname in lower case before saving into database but insights registration accepts upper case characters. This causes a resolution issue in code : 

File :  /opt/theforeman/tfm/root/usr/share/gems/gems/redhat_access-2.2.0/app/models/redhat_access/concerns/host_managed_extensions.rb
Line :  host_ids = Host::Managed.where(:name => hostname_rules_relation.keys).pluck(:id)

Abov search is case sensitive and remdeiation fials with error :
2019-05-07T09:38:31 [E|bac|59729] PG::SyntaxError: ERROR:  syntax error at or near ")"
LINE 1: ... "hosts"."organization_id" = 4 AND (( hosts.id IN())) ORDER ...
: SELECT "hosts"."id" FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 4 AND (( hosts.id IN())) ORDER BY "hos
ts"."name" ASC (ActiveRecord::StatementInvalid)
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:616:in `async_exec'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:616:in `block (2 levels) in exec_no_cache'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'

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

How reproducible:

Steps to Reproduce:
1. Register a system with satellite which has uppercase characters in hostname. Also register the same to insights
2. Run a remeditaion playbook and it will fail

Additional info:

A workaround is to re register the system with insights with lowercase characters
# insights-client --force-reregister --display-name $(hostname -f | tr [A-Z] [a-z])

Note You need to log in before you can comment on or make changes to this bug.