Skip to content

upgrades: flatten permanent upgrades#119142

Merged
craig[bot] merged 9 commits intocockroachdb:masterfrom
dt:upgrades
Feb 14, 2024
Merged

upgrades: flatten permanent upgrades#119142
craig[bot] merged 9 commits intocockroachdb:masterfrom
dt:upgrades

Conversation

@dt
Copy link
Copy Markdown
Contributor

@dt dt commented Feb 13, 2024

This switches the permanent migrations system from allowing
any migration to be considered permanent to having exactly two
'bootstrap' migrations, one for system tenants specifically and
one for all clusters.

This single bootstrap job can be edited in place to add addition bootstrap
steps, such as creating a new singleton job, as needed, along side a
regular migration that performs the same task during upgrades, typically by
calling the same function in both places. This should simplify bootstrap by
having only one or two jobs to run, instead of some unbounded number.

Release note: none.
Epic: none.

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Feb 13, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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.

So much simpler, thanks!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dt and @stevendanna)


pkg/upgrade/upgrades/upgrades.go line 70 at r1 (raw file):

	upgrade.NewPermanentSystemUpgrade(
		"populate initial version cluster setting table entry",
		clusterversion.VPrimordial3.Version(),

We should remove all the cluster settings that are no longer used (and remove the commentary around Permanent upgrades in cockroach_versions.go).

Copy link
Copy Markdown
Contributor Author

@dt dt left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @stevendanna)


pkg/upgrade/upgrades/upgrades.go line 70 at r1 (raw file):

Previously, RaduBerinde wrote…

We should remove all the cluster settings that are no longer used (and remove the commentary around Permanent upgrades in cockroach_versions.go).

Which cluster settings are no longer used?

@RaduBerinde
Copy link
Copy Markdown
Member

pkg/upgrade/upgrades/upgrades.go line 70 at r1 (raw file):

Previously, dt (David Taylor) wrote…

Which cluster settings are no longer used?

Bleh, I meant cluster versions

@dt dt requested a review from a team February 13, 2024 22:58
Copy link
Copy Markdown
Contributor Author

@dt dt left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @stevendanna)


pkg/upgrade/upgrades/upgrades.go line 70 at r1 (raw file):

Previously, RaduBerinde wrote…

Bleh, I meant cluster versions

Ah, makes sense, removed. Just glad to know there aren't some extra cluster settings relating to upgrade execution.

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

This looks good. I wonder if we want to add a documentation comment somewhere explaining what you need to do when you think you need to modified the bootstrap migrations.

Copy link
Copy Markdown
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:

Reviewed 1 of 6 files at r1, 1 of 1 files at r5, 4 of 6 files at r7, 1 of 3 files at r8, 4 of 5 files at r10, 2 of 2 files at r12, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @dt)


pkg/clusterversion/cockroach_versions.go line 173 at r10 (raw file):

	// VBootstrap versions are associated with bootstrap steps; no new bootstrap
	// versions should be added, as the two bootstrap functions are extended as
	// needed in-place.

[nit] maybe add a pointer to where the bootstrap steps are defined


pkg/upgrade/upgrades/permanent_upgrades.go line 36 at r7 (raw file):

	ctx context.Context, cv clusterversion.ClusterVersion, deps upgrade.SystemDeps,
) error {
	for _, fn := range []upgrade.SystemUpgradeFunc{

[nit] I would make this a global variable and add a comment explaining when it is appropriate to add something here.


pkg/upgrade/upgrades/permanent_upgrades.go line 57 at r7 (raw file):

) error {
	for _, u := range []bootstrapStep{
		{"add users and roles", addRootUser},

[nit] ditto, and what's with the unused strings?

dt added 3 commits February 14, 2024 15:30
Release note: none.
Epic: none.
Release note: none.
Epic: none.
Release note: none.
Epic: none.
dt added 5 commits February 14, 2024 16:05
This switches the permanent migrations system from allowing
any migration to be considered permanent to having exactly two
'bootstrap' migrations, one for system tenants specifically and
one for all clusters.

This single bootstrap job can be edited in place to add addition bootstrap
steps, such as creating a new singleton job, as needed, _along side_ a
regular migration that performs the same task during upgrades, typically by
calling the same function in both places. This should simplify bootstrap by
having only one or two jobs to run, instead of some unbounded number.

Release note: none.
Epic: none.
Release note: none.
Epic: none.
Release note: none.
Epic: none.
Copy link
Copy Markdown
Contributor Author

@dt dt left a comment

Choose a reason for hiding this comment

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

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


pkg/upgrade/upgrades/permanent_upgrades.go line 36 at r7 (raw file):

Previously, RaduBerinde wrote…

[nit] I would make this a global variable and add a comment explaining when it is appropriate to add something here.

I tried pulling this into its own var and commenting on it, but the commentary ended up duplicative with the comment on the functions that ran through the list. I think I want comments on the functions, so I went back to inline lists but with the function comments speaking to the lists they contain. WDYT?


pkg/upgrade/upgrades/permanent_upgrades.go line 57 at r7 (raw file):

Previously, RaduBerinde wrote…

[nit] ditto, and what's with the unused strings?

We had these string names before that documented what each step was doing and I didn't want to lose them, just in case we later decide to e.g. update the job status between steps to reflect which step is running at any given time.

I'll log.Info them for now so they're not unused.

Copy link
Copy Markdown
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_strong: Thanks!

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


pkg/upgrade/upgrades/permanent_upgrades.go line 36 at r7 (raw file):

Previously, dt (David Taylor) wrote…

I tried pulling this into its own var and commenting on it, but the commentary ended up duplicative with the comment on the functions that ran through the list. I think I want comments on the functions, so I went back to inline lists but with the function comments speaking to the lists they contain. WDYT?

Looks great, thanks!

@dt
Copy link
Copy Markdown
Contributor Author

dt commented Feb 14, 2024

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 14, 2024

Build succeeded:

@craig craig bot merged commit a061be2 into cockroachdb:master Feb 14, 2024
@dt dt deleted the upgrades branch February 15, 2024 13:13
rafiss added a commit to rafiss/cockroach that referenced this pull request Nov 23, 2024
This partially reverts commit 129d62a.

It also fixes the roachtest that was added in the previous commit.

In PR cockroachdb#119142, the permanent upgrades were flattened so that they
all have a version of 0.0-x. That means that the last element of
the permanentUpgrades slice has a version of 0.0-4. Clusters that were
bootstrapped with a version from v23.1.0 or later will have rows in
system.migrations for versions 0.0-x, since that is the version where
the permanent upgrades framework was introduced (in PR cockroachdb#119142).
However, clusters that are were bootstrapped from a version
earlier than v23.1 will not yet have these rows in system.migrations for
versions 0.0-x, and those migrations will only be present under the
legacy startupmigrations key.

Release note (bug fix): Fixed a bug that could cause the password for
the root user to be deleted while upgrading to v24.1. This bug only
affects clusters that were initially created with a version of v22.2
or earlier.

The same bug could also cause the `defaultdb` and `postgres` databases
to be recreated during the upgrade to v24.1 if they had been previously
deleted.
rafiss added a commit to rafiss/cockroach that referenced this pull request Nov 26, 2024
This partially reverts commit 129d62a.

It also fixes the roachtest that was added in the previous commit.

In PR cockroachdb#119142, the permanent upgrades were flattened so that they
all have a version of 0.0-x. That means that the last element of
the permanentUpgrades slice has a version of 0.0-4. Clusters that were
bootstrapped with a version from v23.1.0 or later will have rows in
system.migrations for versions 0.0-x, since that is the version where
the permanent upgrades framework was introduced (in PR cockroachdb#91627).
However, clusters that are were bootstrapped from a version
earlier than v23.1 will not yet have these rows in system.migrations for
versions 0.0-x, and those migrations will only be present under the
legacy startupmigrations key.

Release note (bug fix): Fixed a bug that could cause the password for
the root user to be deleted while upgrading to v24.1. This bug only
affects clusters that were initially created with a version of v22.2
or earlier.

The same bug could also cause the `defaultdb` and `postgres` databases
to be recreated during the upgrade to v24.1 if they had been previously
deleted.
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.

4 participants