Bug 1693722

Summary: Warn when custom attributes contain spaces in their names - they will not work properly in all of reporting
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: ReportingAssignee: Joe Rafaniello <jrafanie>
Status: CLOSED ERRATA QA Contact: Parthvi Vala <pvala>
Severity: medium Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: unspecifiedCC: agrare, dmetzger, fdewaley, gmccullo, jocarter, jprause, jrafanie, lavenel, lsmola, mfeifer, obarenbo, pvala, simaishi
Target Milestone: GAKeywords: FutureFeature, RFE, ZStream
Target Release: 5.10.3   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: 5.10.3.0 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 1662319 Environment:
Last Closed: 2019-04-23 07:46:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On: 1662319    
Bug Blocks:    

Comment 2 CFME Bot 2019-03-29 17:31:22 UTC
New commit detected on ManageIQ/manageiq/hammer:

https://github.com/ManageIQ/manageiq/commit/14e100cf68085524e229ccdf34fe8acdfa82d85d
commit 14e100cf68085524e229ccdf34fe8acdfa82d85d
Author:     Adam Grare <agrare>
AuthorDate: Tue Mar 19 06:42:19 2019 -0400
Commit:     Adam Grare <agrare>
CommitDate: Tue Mar 19 06:42:19 2019 -0400

    Merge pull request #18538 from jrafanie/deprecate_invalid_column_names_in_custom_attributes

    Deprecate invalid custom attribute names

    (cherry picked from commit a26aa9ddbbb52e9b2027c199cd7782fc8a68c8cb)

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1693722

 app/models/mixins/custom_attribute_mixin.rb | 9 +
 spec/models/mixins/custom_attribute_mixin_spec.rb | 34 +
 2 files changed, 43 insertions(+)

Comment 3 Parthvi Vala 2019-04-08 10:30:52 UTC
Hey Joe,

From what I make of the comments on PR(https://github.com/ManageIQ/manageiq/pull/18538), the problem has not been completely fixed, but a warning is logged somewhere when a custom attribute is created with an invalid name.
I was able to reproduce this BZ, I tested it by creating CA via both REST API and rails console, but I could not see warning anywhere in any of the logs. Can you tell me which log am I supposed to check?

Thanks,
Parthvi

Comment 4 Joe Rafaniello 2019-04-08 14:03:20 UTC
Parthvi, how are you creating the custom attributes?  The methods that are currently raising a deprecation are the common ones used to do this via the custom attribute mixin.  If you bypass the mixin and create the custom attribute directly, it will not log a deprecation warning.

Comment 5 Parthvi Vala 2019-04-08 14:15:18 UTC
I created them via REST API and rails console.
1) via REST API
POST /api/vms/:id/custom_attributes
Query: {
           "action" : "add",
           "resources" : [
               { "name" : "CA with space API", "value" : "value not displayed API" },
               { "name" : "CAwithoutspaceAPI", "value" : "value displayed API" }
           ]
       }
2) via Rails Console:
$evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)
vm  = $evm.vmdb('vm').find_by_name(:vm_name)
vm.custom_set(key, value)

I am not sure if any of these used custom attribute mixin. If they did not, can you tell me how to create the custom attribute via mixin?

Comment 6 Parthvi Vala 2019-04-08 16:47:44 UTC
Forgot to do it in the last comment #5, so adding a needinfo here.

Comment 7 Joe Rafaniello 2019-04-08 17:50:45 UTC
!) this will not raise a deprecation yet
2) this will raise a deprecation

config.active_support.deprecation in vmdb/config/environments/production.rb is set to :notify by default.  Change it to :log to see the deprecations in the rails log, matching the environment, probably production.log.

When people develop their automate code in development mode, this is the default and it will be seen without changing anything.

Comment 8 Parthvi Vala 2019-04-09 05:43:17 UTC
FIXED. Verified the fix for BZ on 5.10.3. The production log logs warning when invalid CA name is set.

Comment 10 errata-xmlrpc 2019-04-23 07:46:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:0796