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

Stack Checker causes CC not to start if upgrading from an older CAPI release #463

Closed
Samze opened this issue Aug 27, 2024 · 2 comments
Closed

Comments

@Samze
Copy link
Contributor

Samze commented Aug 27, 2024

Issue

Logic to check for deprecated stacks was added and is currently being run before migrations, see here. This runs before migrations so that if someone is using a deprecated stack, the checker fails before migrations are run so that you are not left in a state where new migrations have run but you are running old CC code.

However, this Stack Checker rake task loads all models, https://github.com/cloudfoundry/cloud_controller_ng/blob/main/lib/tasks/stack_check.rake . This causes issues when migrations have not run yet and there is a migration that is required for the model load to complete. For example adding a new table, which was done recently https://github.com/cloudfoundry/cloud_controller_ng/blob/main/db/migrations/20240514113500_create_cnb_lifecycle_data.rb . This will cause CC to fail to start as the Stack checker rake task will fail with something like in pre-start:

[2024-08-27 15:24:42+0000] + bundle exec rake stacks:stack_check
[2024-08-27 15:24:47+0000] rake aborted!
[2024-08-27 15:24:47+0000] Sequel::DatabaseError: Mysql2::Error: Table 'cloud_controller.cnb_lifecycle_data' doesn't exist (Sequel::DatabaseError)
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query'
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `block in query'
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `handle_interrupt'
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `query'
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/sequel-5.83.1/lib/sequel/adapters/mysql2.rb:142:in `block in _execute'
[2024-08-27 15:24:47+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/sequel-5.83.1/lib/sequel/database/logging.rb:38:in `log_connection_yield'
[2024-08-27 15:24:48+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/honeycomb-beeline-3.1.0/lib/honeycomb/integrations/sequel.rb:17:in `log_connection_yield'
[2024-08-27 15:24:48+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/sequel-5.83.1/lib/sequel/adapters/mysql2.rb:137:in `_execute'
[2024-08-27 15:24:48+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/sequel-5.83.1/lib/sequel/adapters/utils/mysql_mysql2.rb:40:in `block in execute'
[2024-08-27 15:24:48+0000] /var/vcap/data/packages/cloud_controller_ng/a761d212d4175fe3f27777c61f0de6428e52f8b4/gem_home/ruby/3.2.0/gems/sequel-5.83.1/lib/sequel/connection_pool/threaded.rb:88:in `hold'

This issue is present in CAPI Release 1.190.0 https://github.com/cloudfoundry/capi-release/releases/tag/1.190.0 and may be hit if upgrading from an older capi release where the delta in migrations contains new tables.

Possible Fix

Do not load all models in stack checker, or better yet load no models and just use raw sql.

@Samze
Copy link
Contributor Author

Samze commented Aug 28, 2024

Fix here: cloudfoundry/cloud_controller_ng#3941

@Samze Samze closed this as completed Aug 30, 2024
@Samze
Copy link
Contributor Author

Samze commented Aug 30, 2024

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

1 participant