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 #38022 - Do not use undefined setting #929

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

adamlazik1
Copy link
Contributor

Sometimes the production.log is filled with a message: "Setting remote_execution_workers_pool_size has no definition, please define it before using"

This message does not appear to be a blocker to any of the existing functionalities, however; it is misleading while troubleshooting the issues.

ForemanTasks.dynflow.config.queues.add(DYNFLOW_QUEUE, :pool_size => Setting['remote_execution_workers_pool_size']) if Setting.table_exists? rescue(false)
ForemanTasks.dynflow.config.queues.add(DYNFLOW_QUEUE, :pool_size => Setting['remote_execution_workers_pool_size']) if Setting.find_by :name => 'remote_execution_workers_pool_size' rescue(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

First, this behaves differently than it used to:

# With this patch
> Foreman::Application.dynflow.world.config.queue
=> {:default=>{:pool_size=>5}}

# Without this patch
> Foreman::Application.dynflow.world.config.queue
=> {:default=>{:pool_size=>5}, :remote_execution=>{:pool_size=>5}}

From what I've seen the initializer is invoked before the settings are initialized, so Settings[key] always logs a warning and returns nil. The nil is then stored deep in dynflow's internals in https://github.com/Dynflow/dynflow/blob/93060070e6169af7a27b3821942880c336a91b87/lib/dynflow/config.rb#L67 before it is overriden to a dynflow global default https://github.com/Dynflow/dynflow/blob/93060070e6169af7a27b3821942880c336a91b87/lib/dynflow/config.rb#L72 , so there's a difference between calling this with a nil value and not calling this at all.

That being said, the pool_size is only used in development. In production we use a multi-process deployment using Sidekiq, where creation of queues is handled externally, however dynflow still needs to be aware of the queues' existence.

Right now I'd say we have three options:

  1. Somehow ensure that the queues are configured after the settings are initialized
  2. Drop the setting altogether, just register the queue without requesting a particular size for it and let dynflow use whatever default values it deems appropriate
  3. Drop the setting altogether and hardcode some value here

@ofedoren opinions?

Copy link
Member

Choose a reason for hiding this comment

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

  1. I'd love that. But I still don't quite follow our initialization process, it makes me hate both chickens and eggs... Can dynflow be initialized/used after everything is done in Rails and Foreman+Plugins, but before the first request? Must it be initialized before Foreman, but after Rails? When then we should initialize settings if it needs Setting class, which is initialized as a constant somewhere during Rails initialization? Not even sure if initialization of Foreman starts when or after Zeitwerk does it thing. Also, plugin initialization and registration is also... weird...
  2. If we can do that, why we did put here a value at first place? (Just asking since (for me) after all these years dynflow is still a black magic box Pandora never dreamed of)
  3. If only we didn't show this setting to users before... I mean, no idea if anyone actually changed the value there, thus :/ But if no one used that, it's the best since it's the easiest solution, thus :)

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. ... it makes me hate both chickens and eggs...

Yeah... I must admit I don't really have answers to the things you asked about and overall the effort needed to pull this off just doesn't feel worth it.

  1. If we can do that, why we did put here a value at first place? (Just asking since (for me) after all these years dynflow is still a black magic box Pandora never dreamed of)

It used to be honored before we switched to sidekiq in foreman 1.24. Now it is just a leftover and something that could be used in development, but I'm not sure if anyone actually does that.

Now that I've slept on it, I would lean more towards dropping the setting completely, unless anyone objects against it

Copy link
Member

Choose a reason for hiding this comment

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

I don't think anyone touches anything related to dynflow in development except maybe for you and some Katello guys? If it's also a leftover and isn't used in production, let's drop that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting removed.

Copy link
Member

Choose a reason for hiding this comment

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

Don't we also need a migration to remove it from DB?..

Copy link
Contributor

Choose a reason for hiding this comment

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

@adamlazik1 ^ it would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@adamlazik1 adamlazik1 force-pushed the no-def-setting branch 2 times, most recently from 0639b6b to 80e9626 Compare November 26, 2024 15:46
Sometimes the production.log is filled with a message: "Setting
remote_execution_workers_pool_size has no definition, please define it
before using"

This message does not appear to be a blocker to any of the existing
functionalities, however; it is misleading while troubleshooting the
issues.
@adamruzicka adamruzicka merged commit 91d1152 into theforeman:master Nov 27, 2024
21 of 22 checks passed
@adamruzicka
Copy link
Contributor

Thank you @adamlazik1 !

@adamlazik1 adamlazik1 deleted the no-def-setting branch November 27, 2024 11:09
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