Skip to content

Conversation

joshuay03
Copy link
Contributor

@joshuay03 joshuay03 commented Dec 24, 2023

Description

Closes #3044

CLI options are parsed during CLI initialisation, but after Configuration initialisation. This PR changes this so that the parsing takes place during Configuration initialisation. This ensures that CLI options are also used when some config defaults are conditionally set during initialisation.

Note: Even with the changes in this PR preload_app isn't enabled by default if using #workers in a config file. I'm happy to address that here too if prefered. Else we have an inconsistency with the cli and config file.

Addressed in these changes. We now ensure that conditional defaults are also set when config files are loaded.

Warning

The side effect of these changes which fixes the linked issue is that preload_app is now consistently enabled by default regardless of configuration method if these conditions are met.

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from f977233 to 3ac0f65 Compare December 24, 2023 09:49
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from 3ac0f65 to d4f9f5d Compare December 24, 2023 10:17
@joshuay03 joshuay03 changed the title [Fix #3044] Set conditional config defaults after CLI options are parsed [Fix #3044] Set conditional config defaults after CLI options are parsed and config files are loaded Dec 24, 2023
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 2 times, most recently from 0b9d9ed to 3caaef8 Compare December 24, 2023 10:29
@dentarg
Copy link
Member

dentarg commented Dec 24, 2023

Are the test failures related to (these) tests now using preloading (and that causes some problem)?

While #3044 is classed as a bug, it is quite the change in behaviour... so maybe the fix should be shipped in a major version?

@joshuay03
Copy link
Contributor Author

joshuay03 commented Dec 25, 2023

Are the test failures related to (these) tests now using preloading (and that causes some problem)?

I think some of the phased restart failures are because of this clause. We should just make fork_worker one of the conditions to not default preload_app to true if they conflict. Addressed in these changes. I'll come back and figure out the remaining failures after the break. Merry Christmas 🎄

Edit:

I think I misunderstood that condition. It seems that preload_app is compatible fork_worker, but incompatible with pure phased restart. So the real fix is to make preload_app disabled explicitly in these tests. Addressed in:


While #3044 is classed as a bug, it is quite the change in behaviour... so maybe the fix should be shipped in a major version?

I agree, and yes the issue was added to the 7.0.0 milestone.

@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from 3caaef8 to dbb42e6 Compare December 25, 2023 00:52
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 8 times, most recently from 4b7d90d to fe5dec5 Compare January 2, 2024 22:54
@dentarg dentarg added waiting-for-review Waiting on review from anyone v7 Breaking changes for v7 labels Apr 8, 2024
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from fe5dec5 to ace3c3f Compare April 16, 2024 11:02
@dentarg dentarg added this to the 7.0.0 milestone Jun 5, 2024
@github-actions github-actions bot added waiting-for-merge and removed waiting-for-review Waiting on review from anyone labels Nov 23, 2024
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 3 times, most recently from 3ae362c to e9fb62a Compare November 24, 2024 06:06
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from ced1461 to 1ceab3c Compare February 3, 2025 12:01
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 5 times, most recently from 00108d0 to 3052d13 Compare February 11, 2025 21:36
@joshuay03
Copy link
Contributor Author

I've updated this to target #3616. Once that has been merged, this should go green after rebasing.

@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 2 times, most recently from 0f26974 to 6a2c61b Compare February 11, 2025 22:04
@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 2 times, most recently from 174dbe7 to e24adde Compare August 2, 2025 02:52
@joshuay03
Copy link
Contributor Author

I've updated this to target #3616. Once that has been merged, this should go green after rebasing.

Nvm, I've just patched those tests here. Now neither is dependant on the other and both should cleanly rebase after the other is merged.

@schneems schneems requested a review from nateberkopec August 12, 2025 22:18
@schneems
Copy link
Contributor

I'm not sure why but the UX is telling me that @nateberkopec requested changes even though I don't see the request (and I see an approval from him). All tests are now green. @nateberkopec can you merge in or re-iterate your concerns that seem to have been lost to the snads of time?

@joshuay03
Copy link
Contributor Author

joshuay03 commented Aug 12, 2025

I'm not sure why but the UX is telling me that @nateberkopec requested changes even though I don't see the request (and I see an approval from him). All tests are now green. @nateberkopec can you merge in or re-iterate your concerns that seem to have been lost to the snads of time?

It was because there was a test failure:

Test fails? 🤔

Which has since been resolved:

The last failure is related to #3557 (comment)

I'm pretty sure we want fork_worker enabled for that test, and here I've also disabled preloading for consistency with the other tests since it's not compatible with phased restart. However, enabling fork_worker seems to slow the test down enough for it to time out.

Edit: Resolved in #3589

@MSP-Greg
Copy link
Member

Now neither is dependant on the other and both should cleanly rebase

Re #3616, just checking if the above is still true. I haven't looked much at this one, but @nateberkopec went thru it...

@joshuay03
Copy link
Contributor Author

joshuay03 commented Aug 20, 2025

Now neither is dependant on the other and both should cleanly rebase

Re #3616, just checking if the above is still true. I haven't looked much at this one, but @nateberkopec went thru it...

Probably not with my recent changes. Once #3616 has been merged, I'll come and clean this up. I might have to update the #clamp changes and I can remove some unnecessary #load calls in tests.

FWIW, if I had to pick a PR (of mine) that definitely should go out with v7, it would be this one. I've worked with 2 monoliths now where they almost set WEB_CONCURRENCY without realising they would be enabling preloading, thinking that when they bumped to v5, preloading was already enabled. It's quite confusing default behaviour. We should also include a big warning next to this PR in the changelog that bumping to v7 would enable preloading by default if in cluster mode, regardless of whether the configuration is done via DSL or env var, and that people should set preload_app!(false) to maintain current behaviour—highly advised because you need to be careful when enabling this if you have threads spawned on boot.

cc @schneems

@schneems
Copy link
Contributor

#3616 is merged. Can you rebase on master/main (thanks).

@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch 4 times, most recently from f5fe418 to 29ddb58 Compare August 25, 2025 22:47
@MSP-Greg
Copy link
Member

MSP-Greg commented Aug 25, 2025

Cancel 'older' CI tests?

@joshuay03
Copy link
Contributor Author

Cancel 'older' CI tests?

Yes please, thank you!

@joshuay03 joshuay03 force-pushed the set-conditional-config-defaults-after-cli-options-parse branch from 29ddb58 to 62036f4 Compare August 25, 2025 23:13
@joshuay03
Copy link
Contributor Author

#3616 is merged. Can you rebase on master/main (thanks).

Done 👍🏽

@MSP-Greg MSP-Greg dismissed nateberkopec’s stale review August 26, 2025 00:23

PR has been open since Dec-2023, and the requested changes aren't apparent.

@MSP-Greg MSP-Greg merged commit 6064d15 into puma:master Aug 26, 2025
126 of 127 checks passed
@joshuay03 joshuay03 moved this from In Progress / Pending Review to Done in Open Source Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v7 Breaking changes for v7 waiting-for-changes Waiting on changes from the requestor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

preload_app doesn't default to true if more than 1 worker
5 participants