Bug 1550157 - configure_server_settings.rb changes numeric values to strings, causing failures when other code is expecting integers
Summary: configure_server_settings.rb changes numeric values to strings, causing failu...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Joe Rafaniello
QA Contact: Tasos Papaioannou
URL:
Whiteboard:
Depends On:
Blocks: 1552804
TreeView+ depends on / blocked
 
Reported: 2018-02-28 16:30 UTC by Joe Rafaniello
Modified: 2019-02-11 14:04 UTC (History)
4 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1552804 (view as bug list)
Environment:
Last Closed: 2019-02-11 14:04:45 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Joe Rafaniello 2018-02-28 16:30:04 UTC
Description of problem: Changing the worker count across our environment for ems_metrics_collector_worker from 2 to 4 (using tools/configure_server_settings.rb) caused C & U to stop function because the value was change from 2 to '4'. Subsequently miq_worker.rb:149 was trying to compare current workers [0] to ['4'] and throwing a string comparison exception.


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


How reproducible:


Steps to Reproduce:
1. ./tools/configure_server_settings.rb -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count -v 4

2.
3.

Actual results:
Changes the count to "4" as a String.  Results in an exception when comparing the current worker count to the desired "4" because it's not a number.


Expected results:
changes the count to 4, as a number.

Additional info:

Comment 1 Joe Rafaniello 2018-02-28 16:31:44 UTC
Upstream PRs have been merged:
https://github.com/ManageIQ/manageiq/pull/17039
https://github.com/ManageIQ/manageiq/pull/17059

Comment 2 Joe Rafaniello 2018-03-01 17:10:09 UTC
QE:
Upstream PRs are merged, the desired result is if you try to specify a number and it's treated as a string (how ruby handles anything in ARGV), we should yell at you:

$ ./tools/configure_server_settings.rb -s1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count -v 4
{:dry_run=>false, :serverid=>1, :path=>"workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count", :value=>"4", :force=>false, :type=>"string", :help=>false, :serverid_given=>true, :path_given=>true, :value_given=>true}
** Using session_store: ActionDispatch::Session::MemCacheStore
The new value's class String does not match the prior one's Integer. Use -t to specify the type for the provided value. Use -f to force changing this value. Note, -f may break things! See -h for examples.


You are forced to 
1) use -f to force the script to store the "4" value, which is what you normally don't want to do.

2) or to specify the type.

$ ./tools/configure_server_settings.rb -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count -v 4 -t integer
{:dry_run=>false, :serverid=>1, :path=>"workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count", :value=>"4", :force=>false, :type=>"integer", :help=>false, :serverid_given=>true, :path_given=>true, :value_given=>true, :type_given=>true}
** Using session_store: ActionDispatch::Session::MemCacheStore
Setting [workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count], old value: [2], new value: [4]
Done


Note, --help or -h shows the possible values for the datatype:

$  ./tools/configure_server_settings.rb -h
USAGE:   ./tools/configure_server_settings.rb -s <server id> -p <settings path separated by a /> -v <new value>
Example (String):  ./tools/configure_server_settings.rb -s 1 -p reporting/history/keep_reports -v 3.months
Example (Integer): ./tools/configure_server_settings.rb -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count -v 1 -t integer
Example (Boolean): ./tools/configure_server_settings.rb -s 1 -p ui/mark_translated_strings -v true -t boolean
Example (Symbol):  ./tools/configure_server_settings.rb -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/poll_method -v escalate -t symbol
Example (Float):   ./tools/configure_server_settings.rb -s 1 -p capacity/profile/1/vcpu_commitment_ratio -v 1.5 -t float
  -d, --dry-run         Dry Run
  -s, --serverid=<i>    Server Id
  -p, --path=<s>        Path within advanced settings hash
  -v, --value=<s>       New Value for setting
  -f, --force           Force change value regardless of type
  -t, --type=<s>        Type of value provided, ["string", "integer", "boolean", "symbol", "float"] (default: string)
  -h, --help            Show this message

Comment 4 Tasos Papaioannou 2018-09-19 18:45:00 UTC
Verified on 5.10.0.15.


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