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

Always run pulpcore-manager migrate #351

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# @api private
class pulpcore::database (
Integer[0] $timeout = 3600,
Boolean $always_run_migrations = true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] should this default to false (idempotent by default for people using the puppet module directly), with hiera in foreman-installer providing a true value for our purposes?

as an added benefit, the acceptance test here wouldn't rely on a non-default value... but is there a major downside that I'm overlooking?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's option 1 from #351 (review) and yes we can certainly make that change.

The thing is, that will make the default installation by definition broken.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, I missed that review comment... thanks!

The thing is, that will make the default installation by definition broken.

since this is the first time the issue has occurred, it seems reasonable to me to assume that the types of changes requiring a --migrate run despite no pending migrations would be infrequent.

it also occurs to me now that the pulp folks could accompany such future changes with an empty dummy migration if we ask nicely... in theory, I think we could even submit such a patch to pulp and then simply revert this one here -- what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah nevermind my idea about dummy migrations, I see the comment about pulp/pulpcore#952 now

Copy link
Member Author

@evgeni evgeni Aug 14, 2024

Choose a reason for hiding this comment

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

since this is the first time the issue has occurred, it seems reasonable to me to assume that the types of changes requiring a --migrate run despite no pending migrations would be infrequent.

While I agree such changes are probably infrequent, those are exactly the things you want to have smoothly as otherwise you'll forget or never learn about the special cases before things are broken ;-)

In this particular case we only caught it because the upgrade happened between 3.49.16 and 3.49.17. If it'd be a 3.39.z to 3.49.z, there would have been migrations and it would have went unnoticed.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if Pulp could somehow extend https://github.com/django/django/blob/main/django/core/management/commands/migrate.py to just always return true on --check instead of lying. But it does not look easily extensible. Hooking into the planner is also something not for the faint of heart.

Copy link
Member Author

Choose a reason for hiding this comment

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

wouldn't it make it non-idempotent again (for Puppet) if --check always returns true?

Copy link
Member

Choose a reason for hiding this comment

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

It would need to verify if all roles that need to exist actually exist

) {
if $pulpcore::postgresql_manage_db {
include postgresql::client
Expand All @@ -28,9 +29,17 @@
Class['postgresql::server::service'] ~> Service['pulpcore-content.service']
}

# By default we want to always run `migrate`, even if `--check` returns no pending migrations
# This is due to the fact that Pulp uses post_migration hooks that need to be executed even
# when no real migration has happened.
$migrate_unless = $always_run_migrations ? {
ekohl marked this conversation as resolved.
Show resolved Hide resolved
false => 'pulpcore-manager migrate --check',
default => undef,
}

pulpcore::admin { 'migrate --noinput':
timeout => $timeout,
unless => 'pulpcore-manager migrate --check',
unless => $migrate_unless,
refreshonly => false,
}

Expand Down
1 change: 1 addition & 0 deletions spec/acceptance/hieradata/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ apache::default_mods: false
pulpcore::apache_https_cert: '/etc/pulpcore-certs/ca-cert.pem'
pulpcore::apache_https_key: '/etc/pulpcore-certs/ca-key.pem'
pulpcore::apache_https_ca: '/etc/pulpcore-certs/ca-cert.pem'
pulpcore::database::always_run_migrations: false
Loading