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

migration: provide a hook to implement preconditions #68242

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

ajwerner
Copy link
Contributor

This change augments the migration infrastructure with an optional
hook for tenant migrations to express preconditions that will prevent
any attempt to push the cluster version to a version which requires
this migration to run.

This will be helpful to prevent scenarios where user migrations are doomed
to fail based on current state in the database but that would only be
determined after the cluster had locked out the older version.

Release note: None

@ajwerner ajwerner requested review from knz and RaduBerinde July 29, 2021 16:09
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner and @knz)


pkg/migration/tenant_migration.go, line 103 at r1 (raw file):

	ctx context.Context, cv clusterversion.ClusterVersion, d TenantDeps,
) error {
	if m.precondition == nil {

[nit] I think it would be good to require a non-nil precondition function, to force whoever is adding a migration to consider this aspect. We can define a NoPreconditionFn to use when it's not needed.

This change augments the migration infrastructure with an optional
hook for tenant migrations to express preconditions that will prevent
any attempt to push the cluster version to a version which requires
this migration to run.

This will be helpful to prevent scenarios where user migrations are doomed
to fail based on current state in the database but that would only be
determined after the cluster had locked out the older version.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/migration-preconditions branch from 8af77c2 to 26eaca0 Compare August 10, 2021 18:25
@ajwerner ajwerner changed the title [WIP] migration: provide a hook to implement preconditions \migration: provide a hook to implement preconditions Aug 10, 2021
@ajwerner ajwerner changed the title \migration: provide a hook to implement preconditions migration: provide a hook to implement preconditions Aug 10, 2021
Copy link
Contributor Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Added testing and made the precondition required. PTAL.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @knz)


pkg/migration/tenant_migration.go, line 103 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] I think it would be good to require a non-nil precondition function, to force whoever is adding a migration to consider this aspect. We can define a NoPreconditionFn to use when it's not needed.

Done.

@ajwerner ajwerner requested a review from fqazi August 10, 2021 18:26
@ajwerner ajwerner marked this pull request as ready for review August 10, 2021 18:26
@ajwerner ajwerner requested a review from a team as a code owner August 10, 2021 18:26
@ajwerner ajwerner requested a review from a team August 10, 2021 18:26
Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @knz)

@ajwerner
Copy link
Contributor Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 10, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 11, 2021

Build succeeded:

@craig craig bot merged commit 7e22bd5 into cockroachdb:master Aug 11, 2021
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

Successfully merging this pull request may close these issues.

None yet

4 participants