cloudfoundry / capi-release

Bosh Release for Cloud Controller and friends
Apache License 2.0
24 stars 101 forks source link

Revert "Run stack_check after DB migrations and seeds (#453)" #454

Closed xandroc closed 3 months ago

xandroc commented 3 months ago

This reverts commit f445c39c88fd3b0f5efed7d873bd2c0198a0a299.

We can now run the stack checker before migrations as per https://github.com/cloudfoundry/cloud_controller_ng/pull/3925.

This is an improvement as we want to fail the stack checker before any migrations have run so that we are not in a state where migrations have run but the deployment has failed

philippthun commented 3 months ago

I'm still unsure if this works for a from-scratch setup (as it's done in the CAPI CI pipeline for three environments). I think at this time - i.e. the very first time this runs on a vm on a new foundation - the database is completely empty (no tables etc.). So loading the models should actually fail...

xandroc commented 3 months ago

I'm still unsure if this works for a from-scratch setup (as it's done in the CAPI CI pipeline for three environments). I think at this time - i.e. the very first time this runs on a vm on a new foundation - the database is completely empty (no tables etc.). So loading the models should actually fail...

Thanks @philippthun, perhaps we can detect if any migrations have run at all do you have any recommendations on how we might do that?

philippthun commented 3 months ago

@xandroc Hm, maybe connect to the database and check if the migrations table exists:

db = VCAP::CloudController::DB.connect(RakeConfig.config.get(:db), logger)
return unless db.table_exists?(:schema_migrations)

...
xandroc commented 3 months ago

Thanks @philippthun we added a variation, schema_migrations table does exist prior to migrations running so we checked for stacks table next unless db.table_exists?(:stacks)

https://github.com/cloudfoundry/cloud_controller_ng/pull/3925/commits/d854dab925fbba59c347f08d6e523b4fe5b4407b

xandroc commented 3 months ago

@philippthun can you give the changes in this pr a review, thanks

Samze commented 3 months ago

LGTM given https://github.com/cloudfoundry/cloud_controller_ng/pull/3925