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

Conversation

ofedoren
Copy link
Member

@ofedoren ofedoren commented Feb 9, 2024

No description provided.

Comment on lines 10 to +13
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
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?

@ofedoren ofedoren changed the title Ruby 3 minimal changes Fixes #37103 - Ruby 3.0 support Feb 12, 2024
@ofedoren ofedoren marked this pull request as ready for review February 12, 2024 14:34
@ofedoren
Copy link
Member Author

ofedoren commented Feb 12, 2024

Jeez.. 2.7 failure is just... such random. I'll rebase the branch just in case :/

@adamruzicka, any idea why it fails?..

private

def extract_concurrency_limit(args = [], limit = nil)
args.find { |arg| arg.is_a?(Hash) && arg.key?(:concurrency_limit) }&.fetch(:concurrency_limit, limit)
Copy link
Member

@evgeni evgeni Feb 13, 2024

Choose a reason for hiding this comment

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

My Ruby is bad, but doesn't this mean:

  1. take args
  2. find the first element in it that is a Hash and has a concurrency_limit key
  3. if found, fetch the value from that Hash. if not found, don't do anything as find returned nil and the safe operator skips the .fetch

so instead, how about:

Suggested change
args.find { |arg| arg.is_a?(Hash) && arg.key?(:concurrency_limit) }&.fetch(:concurrency_limit, limit)
args.find { |arg| arg.is_a?(Hash) && arg.key?(:concurrency_limit) }&.fetch(:concurrency_limit) || limit

Copy link
Member

@evgeni evgeni Feb 13, 2024

Choose a reason for hiding this comment

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

and depending on the Ruby version, calling with (…, concurrency_limit: 25) places that in either args or concurrency_limit and produces 2.7 failures

@evgeni
Copy link
Member

evgeni commented Feb 13, 2024

Also, no pressure, but this PR is the only thing needed to be able to deploy (not pass tests, alas) a Katello on EL9 :)

@evgeni
Copy link
Member

evgeni commented Feb 14, 2024

The tests are passing, and Katello seems to work fine with these changes (even bats is passing once the Ruby3 patch for Katello is applied) \o/

@adamruzicka adamruzicka merged commit 37746ca into theforeman:master Feb 14, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants