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

Run migrations if there are pending migrations #778

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Dec 2, 2019

This drops relying on a settings entry in favor of lettings Rails
tell us when there are migrations that need to be applied.

@ehelms
Copy link
Member Author

ehelms commented Dec 2, 2019

This is an alternative solution to (#776) for at least handling the migrate part of the database.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this because of the simplicity. Looks like we should also drop those settings from Foreman itself after it's been merged.

manifests/database.pp Show resolved Hide resolved
manifests/database.pp Outdated Show resolved Hide resolved
@ehelms ehelms force-pushed the check-pending-migrations branch from 4042601 to b11564c Compare December 2, 2019 17:05
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker to merge, but any thoughts about seeding? I think the refresh can be used to always seed when we migrate, but I wonder about cases where we need to seed without a migration. Since we currently don't that either, I'd be fine with leaving that out.

Once the build is green I'm happy to merge this.

manifests/database.pp Outdated Show resolved Hide resolved
@ehelms
Copy link
Member Author

ehelms commented Dec 2, 2019

I went that route originally -- assume if migration that seed should happen. And had the same thought, seed doesn't require a migration. The seeds are tougher because by design they ought to be idempotent but I think your desire is that the exec is idempotent. So rather than let db:seed determine if changes are necessary, you prefer the exec determine that before running the db:seed. The current logic we live by is if Foreman or a plugin updates, try to db:seed. If the updates were all controlled inside the installer we could use that to notify the db:seed exec. However, we can't control that. I think that leaves us with using a file for seeds unfortunately if the desire is to avoid running db:seed on each puppet run.

@ehelms ehelms force-pushed the check-pending-migrations branch from ff72a49 to 92331aa Compare December 2, 2019 20:24
@ehelms ehelms requested a review from ekohl December 4, 2019 01:58
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the seeding happens because notifications have a transitive property. It's not written in the current tests, but you can:

it { should contain_foreman__rake('db:migrate').that_notifies('Foreman::Rake[db:seed]') }

That actually passes which means that every time a migration happens, a seeding also happens. It's fairly safe to assume that this is enough. Time will tell if there's ever a case something needs to be seeded to work but doesn't have a DB migration.

@@ -14,6 +15,7 @@
logoutput => 'on_failure',
refreshonly => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be false when unless is set. Otherwise the whole trick still doesn't work.

@ehelms
Copy link
Member Author

ehelms commented Dec 6, 2019

A plugin adding notifications is an example of seed with no migration, e.g. theforeman/foreman_ansible@d37ad23#diff-90c017e7983b50d96418476d81b442db

@ekohl
Copy link
Member

ekohl commented Dec 6, 2019

You still need to change the refreshonly code.

A plugin adding notifications is an example of seed with no migration, e.g. theforeman/foreman_ansible@d37ad23#diff-90c017e7983b50d96418476d81b442db

Without this change that isn't covered either. Let's get this in and think about seeding in the next stage.

@ehelms ehelms force-pushed the check-pending-migrations branch from 92331aa to 7348620 Compare December 6, 2019 18:53
manifests/rake.pp Outdated Show resolved Hide resolved
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer an explicit test that passes in an unless to foreman::rake. In https://github.com/theforeman/puppet-foreman/compare/master...ekohl:fixes?expand=1 I've written one.

spec/defines/foreman_rake_spec.rb Outdated Show resolved Hide resolved
manifests/rake.pp Outdated Show resolved Hide resolved
@ehelms ehelms force-pushed the check-pending-migrations branch from d78e335 to 91ddc9c Compare December 7, 2019 01:18
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is failing on this.

Also odd that prometheus is failing. I already disabled that on Debian but now it's failing on centos as well. Perhaps that really is broken.

spec/defines/foreman_rake_spec.rb Outdated Show resolved Hide resolved
This drops relying on a settings entry in favor of lettings Rails
tell us when there are migrations that need to be applied.
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on green tests

@ehelms
Copy link
Member Author

ehelms commented Dec 9, 2019

Looks like further debugging needed as its failing for CentOS 7.

@ekohl
Copy link
Member

ekohl commented Dec 9, 2019

Are you reading what I'm writing?

Also odd that prometheus is failing. I already disabled that on Debian but now it's failing on centos as well. Perhaps that really is broken.

Since then it also looks like master is showing the same issue. That means I'd be ok with just merging this. Alternatively first merging a PR that disables the test similar to c0b9611

@ehelms
Copy link
Member Author

ehelms commented Dec 10, 2019

Sorry, I was. The output just made me think it was a regular curl status check that was failing. I do see now that the test description mentions prometheus.

@ehelms ehelms merged commit bce2704 into theforeman:master Dec 13, 2019
@ehelms ehelms deleted the check-pending-migrations branch December 13, 2019 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants