KnapsackPro / knapsack_pro-ruby

Knapsack Pro gem splits tests across parallel CI nodes and makes sure that tests run in optimal time
https://knapsackpro.com
MIT License
131 stars 27 forks source link

Infinite recursion when KNAPSACK_PRO_LOG_LEVEL is set to debug #269

Open dmytro-workday opened 4 weeks ago

dmytro-workday commented 4 weeks ago

Hi,

We have set KNAPSACK_PRO_LOG_LEVEL=debug and KNAPSACK_PRO_LOG_DIR=log, which leads to the following backtrace:

[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] SystemStackError: stack level too deep (SystemStackError)
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:240:in `map'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:240:in `detected_ci'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:292:in `ci_env_for'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:282:in `env_for'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:20:in `ci_node_index'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro.rb:99:in `logger'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:285:in `env_for'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:20:in `ci_node_index'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro.rb:99:in `logger'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:285:in `env_for'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro/config/env.rb:20:in `ci_node_index'
[2024-08-15 12:56:16] [2024-08-15 12:56:16] [NODE=4] /builds/app/vendor/bundle/ruby/3.2.0/gems/knapsack_pro-7.8.0/lib/knapsack_pro.rb:99:in `logger'

Seems like the issue is related to the following warnings, throws when the logging directory is not enabled:

You have set the environment variable KNAPSACK_PRO_CI_NODE_TOTAL to 36 which could be automatically determined from the CI environment as 9.
You have set the environment variable KNAPSACK_PRO_CI_NODE_INDEX to 1 which could be automatically determined from the CI environment as 0.

The configuration we used is similar to the FAQ answer here:

https://knapsackpro.com/faq/question/parallel_tests-with-knapsack_pro-on-parallel-ci-nodes

ArturT commented 3 weeks ago

@dmytro-workday Could you work around the issue while we look into it? Or is this preventing you from using Knapsack Pro?

dmytro-workday commented 3 weeks ago

Yes. We have removed the _LOG_ variables for now and assigning the logger ourselves instead:

logger = Logger.new("log/knapsack_pro_node_#{KnapsackPro::Config::Env.ci_node_index}.log")
logger.level = ::Logger::DEBUG
KnapsackPro.logger = logger