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

Restoring the Microcluster Schema Migration history #689

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

louiseschmidtgen
Copy link
Contributor

@louiseschmidtgen louiseschmidtgen commented Sep 20, 2024

Restoring the Microcluster Migration History

This PR restores our microcluster schema migration history to the original order.

Issue

We had an issue where the latest migration did not get applied: #634

Cause

The reason for this issue is that a migration was removed without dropping the schema version count. Consequently, when refreshing the snap the microcluster migration thought more migrations were already applied, leaving the latest migration un-applied.

Fix

This PR restores the schema migration order which will need to be back-ported into all 1.31 branches.
It is not good practice to remove a migration, this does not remove the existing table. A second migration should be in place to remove the table maintaining the accurate migration history.

Note on Prefix count

We should have labeled these not at all in the first place. It is not good practice to change the existing migration name (in case microcluster introduces checks around migration names). To stay consistent with the current naming I am continuing the current number prefix.

@louiseschmidtgen louiseschmidtgen requested a review from a team as a code owner September 20, 2024 17:37
Copy link
Contributor

@addyess addyess left a comment

Choose a reason for hiding this comment

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

Questions regarding the migration order

src/k8s/pkg/k8sd/database/schema.go Outdated Show resolved Hide resolved
@louiseschmidtgen louiseschmidtgen changed the title Restoring the microcluster migration history Restoring the Microcluster Schema Migration history Sep 23, 2024
Copy link
Contributor

@HomayoonAlimohammadi HomayoonAlimohammadi left a comment

Choose a reason for hiding this comment

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

Thanks a lot @louiseschmidtgen! left a minor comment for discussion.

src/k8s/pkg/k8sd/database/schema.go Outdated Show resolved Hide resolved
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

LGTM, minor nit

Copy link
Member

@berkayoz berkayoz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for getting in depth with this! I feel like we should have some sort of dev documentation around this process especially on how to maintain these migrations.

@bschimke95
Copy link
Contributor

@berkayoz we recently introduces a comment "don't change the order and only append to the migration" (https://github.com/canonical/k8s-snap/pull/689/files#diff-e146bb0bfd60417d271d4806b46753a797e5d4e2cffc7ac9a334c249311fb816R17) but seems like I didn't stick to my own notes :)

@louiseschmidtgen louiseschmidtgen merged commit c74b9f5 into main Sep 26, 2024
19 of 20 checks passed
@louiseschmidtgen louiseschmidtgen deleted the KU-1598/placeholder-migration branch September 26, 2024 06:14
bschimke95 pushed a commit that referenced this pull request Sep 26, 2024
)

* Correct microcluster schema migration order (#676)
* Restoring the Microcluster Schema Migration History (#689)
evilnick pushed a commit to evilnick/k8s-snap that referenced this pull request Nov 14, 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

Successfully merging this pull request may close these issues.

5 participants