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

Fixes #37103 - Ruby 3.0 support #743

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AllCops:
- 'node_modules/**/*'
- 'locale/*'
- 'vendor/**/*'
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

Lint/ShadowingOuterLocalVariable:
Enabled: false
Expand Down
9 changes: 8 additions & 1 deletion app/lib/actions/bulk_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class BulkAction < Actions::ActionWithSubPlans
# Arguments that all the targets share
def plan(action_class, targets, *args, concurrency_limit: nil, **kwargs)
check_targets!(targets)
limit_concurrency_level!(concurrency_limit) if concurrency_limit
extracted_concurrency_limit = extract_concurrency_limit(args, concurrency_limit)
limit_concurrency_level!(extracted_concurrency_limit) if extracted_concurrency_limit
Comment on lines 10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the concurrency_limit keyword is not used anywhere yet, so we might be able to change the interface if that would help

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would be a bit cleaner. I didn't remove it from the signature with kwargs just in case I missed use case and it is being used somewhere.

Although, from what I found and if I understand the logic right, concurrency_limit: nil, **kwargs is simply ignored due to dynflow doesn't support passing keywords into plan method. Neither foreman-tasks in some places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I'm confused. It must have worked somehow otherwise the test that is now failing on 2.7 would never pass have passed, no?

plan_self(:action_class => action_class.to_s,
:target_ids => targets.map(&:id),
:target_class => targets.first.class.to_s,
Expand Down Expand Up @@ -72,5 +73,11 @@ def batch(from, size)
def total_count
input[:target_ids].count
end

private

def extract_concurrency_limit(args = [], limit = nil)
args.find { |arg| arg.is_a?(Hash) && arg.key?(:concurrency_limit) }&.fetch(:concurrency_limit) || limit
end
end
end
16 changes: 8 additions & 8 deletions app/models/foreman_tasks/concerns/action_triggering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def update_action; end
# @override
def destroy_action; end

def save(*args)
dynflow_task_wrap(:save) { super(*args) }
def save(...)
dynflow_task_wrap(:save) { super(...) }
end

def save!(*args)
dynflow_task_wrap(:save) { super(*args) }
def save!(...)
dynflow_task_wrap(:save) { super(...) }
end

def destroy
Expand All @@ -37,14 +37,14 @@ def destroy

# In order to use host.<attribute>_changed?, we must assign_attributes to
# the host record for these update and update! methods.
def update(*args)
assign_attributes(*args)
def update(...)
assign_attributes(...)
dynflow_task_wrap(:save) { save }
end
alias update_attributes update

def update!(*args)
assign_attributes(*args)
def update!(...)
assign_attributes(...)
dynflow_task_wrap(:save) { save! }
end
alias update_attributes! update!
Expand Down