Bug 1653135

Summary: facts upload failed
Product: Red Hat Satellite Reporter: matt jia <mjia>
Component: Discovery ImageAssignee: Lukas Zapletal <lzap>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.3CC: lzap, mjia, rabajaj
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-29 13:38:22 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 matt jia 2018-11-26 02:36:06 UTC
Description of problem:

With the discovery image v3.4.4-1, even with v3.5.1, fact upload failed with below error:

Validation failed: Name has already been taken, Discovery attributes set can't be blank.

The error is caused by a blank attribute. See the following entries in production.log

2018-11-20 13:22:45 6fd4ba75 [app] [I] Started POST "/api/v2/discovered_hosts/facts" for 10.32.10.136 at 2018-11-20 13:22:45 +0100
2018-11-20 13:22:45 6fd4ba75 [app] [I] Processing by Api::V2::DiscoveredHostsController#facts as JSON
2018-11-20 13:22:45 6fd4ba75 [app] [I]   Parameters: {"facts"=>"[FILTERED]", "apiv"=>"v2", "discovered_host"=>{"facts"=>"[FILTERED]"}}
2018-11-20 13:22:45 6fd4ba75 [app] [I] Current user: foreman_admin (administrator)
2018-11-20 13:22:45 6fd4ba75 [audit] [I] [mac005056aa94cf] deleted 0 (3.5ms)
2018-11-20 13:22:45 6fd4ba75 [audit] [I] [mac005056aa94cf] added 132 (345.2ms)
2018-11-20 13:22:45 6fd4ba75 [app] [W] Host discovery failed, facts: {"lib"=>"/usr/share/fdi/facts:/opt/extension/facts", 
---
---
"discovery_netmask"=>"255.255.255.0", "discovery_gateway"=>"xx.xx.xx.x", "discovery_dns"=>"xx.xx.xx.x", ""=>"",

As you can see, for some reason, the facts has an empty attribute.

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

6.3.4

How reproducible:

Hard as this is only observed in one customer's env

Steps to Reproduce:

use  foreman-discovery-image-3.4.4 image for PXE-less discovery

Actual results:

Can't provision a host.

Expected results:

Can provision a host.

Additional info:

I think empty attributes(still not sure how this happens) should be automatically removed from the discovered facts before sending to the 
Satellite server.