-
Notifications
You must be signed in to change notification settings - Fork 897
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
Successive automation task runs shouldn't change the original params #19158
Successive automation task runs shouldn't change the original params #19158
Conversation
@miq-bot add_label bug, hammer/yes, ivanchuk/yes |
8480ad1
to
ae4cc6b
Compare
@bdunne could I get you to review, please? |
@miq-bot remove_label wip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to better understand the problem...
- I see that the linked change modifies
filter[:parameters]
, but is that a problem? Is the changed record saved? Wouldn't the record be reloaded on the next schedule run? - Should
AutomationRequest#parse_out_objects
modify the input? It seems to me like It should not modify inputs and instead return a duplicate, but I don't really know. Maybe @syncrou or @gmcculloug can help?
@bdunne Yeah, I can see moving this change down into @d-m-u Let me know if you want to work through this together. |
beb22e5
to
e6a6e4a
Compare
parameters.stringify_keys! | ||
create_from_ws("1.1", user, uri_parts, parameters, approval) | ||
uri_parts = uri_parts.stringify_keys | ||
parameters = parameters.stringify_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using stringify_keys
without !
we are dup'ing the objects at the top of the method so uri_parts.delete
that was happening on the first line of the method before will no longer modify the object passed in. 👍
e6a6e4a
to
9bb523e
Compare
@miq-bot remove_label wip |
c769426
to
92b4bc2
Compare
4c412a6
to
20b37fc
Compare
app/models/automation_request.rb
Outdated
object_hash.each do |key, _v| | ||
parameters.delete(key) | ||
end | ||
uri_parts = uri_parts.stringify_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of uri_parts.except(:namespace, :class_name).stringify_keys!
?
20b37fc
to
b80853b
Compare
app/models/automation_request.rb
Outdated
object_hash.each do |key, _v| | ||
parameters.delete(key) | ||
end | ||
uri_parts = uri_parts.except(:namespace, :class_name).stringify_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we can use stringify_keys!
because except
is already creating a new object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah okay, fine fine.
b80853b
to
047b695
Compare
@d-m-u It looks like something got reverted back to the |
@bdunne yeah, I can't look into the spec failure with your suggestion #19158 (comment) just right now, so it's back to when it worked, will get to it tomorrow |
047b695
to
f89526d
Compare
Checked commit d-m-u@f89526d with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Tests are passing. @bdunne PTAL |
…should_not_remove_params Successive automation task runs shouldn't change the original params (cherry picked from commit c86ed36) https://bugzilla.redhat.com/show_bug.cgi?id=1713072
Ivanchuk backport details:
|
…should_not_remove_params Successive automation task runs shouldn't change the original params (cherry picked from commit c86ed36) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1745197
Hammer backport details:
|
Params get removed and re-added here: https://github.com/ManageIQ/manageiq/pull/12722/files#diff-e3295c427cec18ad642950055ae49a3bR53 and on the second run of an automation task that's scheduled, we've lost the relevant attributes.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1713072