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

Chefspec always starts a ZeroServer even if ServerRunner not used #1017

Open
Annih opened this issue Nov 28, 2021 · 2 comments
Open

Chefspec always starts a ZeroServer even if ServerRunner not used #1017

Annih opened this issue Nov 28, 2021 · 2 comments

Comments

@Annih
Copy link
Contributor

Annih commented Nov 28, 2021

Issue description

Despite the fact SoloRunner is the preferred runner for Chef Server / Chef Zero users since version 5.10 (2016-09-14), Chefspec is starting a ZeroServer at the begining of the rspec suite!

This is due to the fact require 'chefspec' triggers the require of most its features including the ServerRunner class which requires the ZeroServer class which automatically configures a before(:suite) hook .

This seems not a critical issue but it may triggers error in CI environment as ZeroServer reserves one port from the range 8889..8899 which can prevent other tests to run properly.

e.g. you can't run 11 chefspecs suites in concurrency! 😿

Expected behavior

  1. Chefspec should not setup a ChefZero server when you do not use ServerRunner!
  2. Disabling ChefZero server should not require any extra configuration

Proposed solutions

As I personally think not starting a ChefZero server should be the default, I will not sugest a solution based on a configuration setting.
Currently I can think of 3 solutions:

  1. do not require the server_runner.rb file by default, forcing people to require it when they want to instanciate the runner.
    ➖ This is obviously a breaking change compared to current state,
    ➕ This solution has the benefits to just remove one require line :
  2. creates a new "require entry_point" to explicitely exclude the server_runner require, something like require 'chefspec/without_server_runner'
    ➖ This needs to change a bit the require list in a non standard way
    ➖ With default require 'chefspec' there is still a ZeroServer spawned
    ➕ This is very explict and impact only people that does not want the ZeroServer
  3. Delay the configuration (setup! but also reset! & teardown!) of the ZeroServer at first ServerRunner initialization
    ➖ This might slow down the first test a bit and have other impact that I do not foresee 🤷🏻‍♂️
    ➕ This only impacts ServerRunner users
    ➕ SoloRunner users are not "impacted" anymore by ServerRunner's features

I prefere solution #3, although as SoloRunner user I would also accept solution #2.
As I'm not using ServerRunner much I would not be annoyed by solution #1 but I can understand that introducing a breaking change for such a minimal issue is not great 🤷🏻‍♂️

Should you have other idea please share them, I'm OK to send a PR with any fix going toward described Expected behavior

@lamont-granquist
Copy link
Contributor

The legacy chef-solo mode should really be removed from the chef-client codebase entirely and chefspec should be switched to ZeroServer always.

The perf issues with the cookbook_versions endpoint go away in a policyfile world where that endpoint is never hit and/or the perf hit of the cookbook_versions endpoint in the chef-zero server should get addressed.

@Annih
Copy link
Contributor Author

Annih commented Mar 10, 2022

Thank you @lamont-granquist for this answer.
I was not expecting that, but if Chef's direction is to completely get rid of the chef-solo mode I understand.

On the long run I'll have to find a nice way to configure the ZeroServer port range in my CI!
Have you any ETA on when chef-solo mode will be removed?
In the meantime would you accept a PR implementing the third option I proposed?

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

No branches or pull requests

2 participants