Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker Settings: save memory threshold as an integer #4633

Merged

Conversation

mzazrivec
Copy link
Contributor

Saving the memory threshold value as a string would prevent the value to be read / used correctly later by the worker itself.

See https://bugzilla.redhat.com/show_bug.cgi?id=1624431#c6

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

Saving the memory threshold value as a string would prevent
the value to be read / used correctly later by the worker itself.

https://bugzilla.redhat.com/show_bug.cgi?id=1624431
@mzazrivec mzazrivec force-pushed the save_worker_memory_threshold_as_integer branch from e89db53 to e602fdf Compare September 10, 2018 14:44
@miq-bot
Copy link
Member

miq-bot commented Sep 10, 2018

Checked commit mzazrivec@e602fdf with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

@mzazrivec mzazrivec changed the title Worker Settings: save memory threshold as integer Worker Settings: save memory threshold as an integer Sep 10, 2018
@@ -835,43 +835,43 @@ def settings_get_form_vars

w = qwb[:generic_worker]
w[:count] = params[:generic_worker_count].to_i if params[:generic_worker_count]
w[:memory_threshold] = params[:generic_worker_threshold] if params[:generic_worker_threshold]
w[:memory_threshold] = params[:generic_worker_threshold].to_i if params[:generic_worker_threshold]
Copy link
Contributor

@himdel himdel Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be using to_i_with_method here?

Or is every single use of 200.megabytes gone?

Because...

200.megabytes.to_i == 200.megabytes == 209715200

but

"200.megabytes".to_i == 200

whereas

"200.megabytes".to_i_with_method == 200.megabytes.to_i_with_method == 209715200

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cc @jrafanie ^

Copy link
Contributor Author

@mzazrivec mzazrivec Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From log:

Processing by OpsController#settings_form_field_changed as JS
INFO -- :   Parameters: {"generic_worker_threshold"=>"367001600", "id"=>"workers"}

i.e. what you're getting from the browser here is "367001600", not "350.megabytes".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah, never mind :)

It looked like the data could come from the db, didn't notice it's always params.

You're right 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for digging into this. Yes, either "350.megabytes"(string) or 367001600(integer) would be acceptable, but not "367001600"(string). This change looks good to me although I'm not quite sure of how the values are transformed from form to backend.

@himdel himdel self-assigned this Sep 17, 2018
@himdel himdel added this to the Sprint 95 Ending Sep 24, 2018 milestone Sep 17, 2018
@himdel himdel merged commit a80af62 into ManageIQ:master Sep 17, 2018
@mzazrivec mzazrivec deleted the save_worker_memory_threshold_as_integer branch September 17, 2018 13:06
simaishi pushed a commit that referenced this pull request Sep 17, 2018
…as_integer

Worker Settings: save memory threshold as an integer
(cherry picked from commit a80af62)

https://bugzilla.redhat.com/show_bug.cgi?id=1629897
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 77d1f5d31a6f3cf2b8d70b345268ce02c94499c9
Author: Martin Hradil <himdel@seznam.cz>
Date:   Mon Sep 17 13:04:11 2018 +0000

    Merge pull request #4633 from mzazrivec/save_worker_memory_threshold_as_integer
    
    Worker Settings: save memory threshold as an integer
    (cherry picked from commit a80af624e42930f1612115f84baf58cff5aeaec6)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1629897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants