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

clusterversion: cockroach versions cleanup #113314

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Oct 30, 2023

This commit cleans up the code and constants in
cockroach_versions.go:

  • we separate out the "dev offset" code and improve the documentation;
  • we replace the key-to-version slice with a table (array). This makes the declaration much cleaner and makes the lookup easier.
  • we replace ByKey() with a method, to make the call site less messy, e.g. clusterversion.ByKey(clusterversion.V23_2) becomes clusterversion.V23_2.Version();
  • we deprecate BinaryMinSupportedVersionKey in favor of MinSupported;
  • we deprecate BinaryVersionKey in favor of Latest;
  • we remove roachpb.Version "constants" in favor of using the Version() method.

Informs: #112629
Release note: None

@blathers-crl
Copy link

blathers-crl bot commented Oct 30, 2023

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde RaduBerinde requested review from dt, rail and celiala October 30, 2023 20:35
@RaduBerinde RaduBerinde marked this pull request as ready for review October 30, 2023 20:36
@RaduBerinde RaduBerinde requested a review from a team as a code owner October 30, 2023 20:36
@RaduBerinde RaduBerinde requested a review from a team as a code owner October 30, 2023 21:20
@RaduBerinde
Copy link
Member Author

I plan to do similar related cleanup (e.g. to the methods of the version Handle) once this is approved.

@RaduBerinde
Copy link
Member Author

Friendly ping

Copy link
Collaborator

@andyyang890 andyyang890 left a comment

Choose a reason for hiding this comment

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

Started reviewing this and it looks pretty good so far! Had a few questions and a small nit.

Reviewed 4 of 15 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aadityasondhi, @celiala, @dt, @RaduBerinde, and @rail)


pkg/clusterversion/cockroach_versions.go line 517 at r1 (raw file):

//
// Note that versions in this table can be modified by applying a "dev offset"
// to ensure that upgrades don't occur between in-developent and relased

nit: s/developent/development/ and s/relased/released/


pkg/clusterversion/dev_offset.go line 41 at r1 (raw file):

// version! For example, on a cluster that is on released version 3, a dev
// binary containing versions 1, 2, 3, and 4 started with this flag would
// renumber only 2-4 to be +1M. It would then step from 3 "up" to 1000002 --
// ... For example, on a cluster that is on released version 3, a dev
// binary containing versions 1, 2, 3, and 4 started with this flag would
// renumber only 2-4 to be +1M. ...

I know this comment was just copied over but I'm kind of confused about this sentence. Is it because we had the implicit assumption before that MinSupported is 1 version lower (i.e. 2 in this example)?


pkg/clusterversion/dev_offset.go line 46 at r1 (raw file):

var devOffsetKeyStart = func() Key {
	forceDev := envutil.EnvOrDefaultBool("COCKROACH_FORCE_DEV_VERSION", false)
	forceRelease := envutil.EnvOrDefaultBool("COCKROACH_TESTING_FORCE_RELEASE_BRANCH", false)

What is the use case for COCKROACH_TESTING_FORCE_RELEASE_BRANCH? It seems like it would be used to allow us to build a non-dev binary from a release branch after it is cut and before we change developmentBranch to false. When would we want to do this?

Also, do we want to rename it to something like COCKROACH_FORCE_NON_DEV_VERSION or something more specific that indicates what exactly we are forcing?

Copy link
Member Author

@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.

Thanks for reviewing!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aadityasondhi, @andyyang890, @celiala, @dt, and @rail)


pkg/clusterversion/cockroach_versions.go line 517 at r1 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

nit: s/developent/development/ and s/relased/released/

Fixed.


pkg/clusterversion/dev_offset.go line 41 at r1 (raw file):

Previously, andyyang890 (Andy Yang) wrote…
// ... For example, on a cluster that is on released version 3, a dev
// binary containing versions 1, 2, 3, and 4 started with this flag would
// renumber only 2-4 to be +1M. ...

I know this comment was just copied over but I'm kind of confused about this sentence. Is it because we had the implicit assumption before that MinSupported is 1 version lower (i.e. 2 in this example)?

Correct, I improved the comment.


pkg/clusterversion/dev_offset.go line 46 at r1 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

What is the use case for COCKROACH_TESTING_FORCE_RELEASE_BRANCH? It seems like it would be used to allow us to build a non-dev binary from a release branch after it is cut and before we change developmentBranch to false. When would we want to do this?

Also, do we want to rename it to something like COCKROACH_FORCE_NON_DEV_VERSION or something more specific that indicates what exactly we are forcing?

It is used for some tests where we actually want to test things as they would happen in the "real" release (as much as possible).

I agree the name could be better but I'm not keen on renaming it in case it is already in use (e.g. in scripts).

@celiala celiala requested a review from andyyang890 November 2, 2023 19:50
Copy link
Collaborator

@celiala celiala left a comment

Choose a reason for hiding this comment

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

O.M.G. - this is such an elegant-looking improvement 😍 -- thank you for doing this!
LGTM!

Reviewed 13 of 15 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aadityasondhi, @andyyang890, @dt, @RaduBerinde, and @rail)


pkg/clusterversion/cockroach_versions.go line 622 at r2 (raw file):

// Note: this is always the last element of SupportedPreviousReleases(); it is
// also provided as a constant for convenience.
const PreviousRelease Key = V23_2

maybe linter to verify that PreviousRelease always equals Latest - 1?


pkg/clusterversion/cockroach_versions.go line 633 at r2 (raw file):

// DEPRECATED: use MinSupported.
const BinaryMinSupportedVersionKey = MinSupported

should we rename BinaryMinSupportedVersionKey to 'DEPRECATED_BinaryMinSupportedVersionKey`? (suggestion for future, not this PR necessarily)


pkg/clusterversion/cockroach_versions.go line 635 at r2 (raw file):

const BinaryMinSupportedVersionKey = MinSupported

// DEPRECATED: use Latest.

(same)


pkg/clusterversion/cockroach_versions.go line 661 at r2 (raw file):

			panic("latest version does not match final version")
		}
		if developmentBranch {

add the "if Previous != Latest - 1 then panic" check here?

Copy link
Member Author

@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.

Thanks!!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aadityasondhi, @andyyang890, @celiala, @dt, and @rail)


pkg/clusterversion/cockroach_versions.go line 622 at r2 (raw file):

Previously, celiala wrote…

maybe linter to verify that PreviousRelease always equals Latest - 1?

Note that it is not "previous version" but "previous release". So it's the last version key before Latest that has Internal = 0.TestKeyConstants verifies the constant.


pkg/clusterversion/cockroach_versions.go line 633 at r2 (raw file):

Previously, celiala wrote…

should we rename BinaryMinSupportedVersionKey to 'DEPRECATED_BinaryMinSupportedVersionKey`? (suggestion for future, not this PR necessarily)

Just adding the comment is enough to make all uses look crossed out in Goland. I plan to clean it up soon, just didn't want to make it all in a huge PR.

Copy link
Collaborator

@andyyang890 andyyang890 left a comment

Choose a reason for hiding this comment

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

:lgtm: This is awesome!

Reviewed 10 of 15 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aadityasondhi, @celiala, @dt, @RaduBerinde, and @rail)


pkg/clusterversion/dev_offset.go line 46 at r1 (raw file):

Previously, RaduBerinde wrote…

It is used for some tests where we actually want to test things as they would happen in the "real" release (as much as possible).

I agree the name could be better but I'm not keen on renaming it in case it is already in use (e.g. in scripts).

Ah got it, would it be possible to maybe add a note documenting it to the comment above devOffsetKeyStart?

@RaduBerinde RaduBerinde force-pushed the version-cleanup branch 2 times, most recently from 728991b to 3b67dcb Compare November 2, 2023 21:26
Copy link
Member Author

@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.

TFTRs!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @aadityasondhi, @andyyang890, @celiala, @dt, and @rail)


pkg/clusterversion/dev_offset.go line 46 at r1 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

Ah got it, would it be possible to maybe add a note documenting it to the comment above devOffsetKeyStart?

Done. Good idea, I added some documentation for both env vars.

@craig
Copy link
Contributor

craig bot commented Nov 2, 2023

Build failed (retrying...):

@renatolabs
Copy link
Contributor

pkg/clusterversion/setting_test.go:69:51: undefined: clusterversion.VCurrent_Start

bors r-

@craig
Copy link
Contributor

craig bot commented Nov 2, 2023

Canceled.

This commit cleans up the code and constants in
`cockroach_versions.go`:
 - we separate out the "dev offset" code and improve the
   documentation;
 - we replace the key-to-version slice with a table (array). This
   makes the declaration much cleaner and makes the lookup easier.
 - we replace `ByKey()` with a method, to make the call site less
   messy; e.g. `clusterversion.ByKey(clusterversion.V23_2)` becomes
   `clusterversion.V23_2.Version()`;
 - we deprecate `BinaryMinSupportedVersionKey` in favor of `MinSupported`;
 - we deprecate `BinaryVersionKey` in favor of `Latest`;
 - we remove `roachpb.Version` "constants" in favor of using the
   `Version()` method.

Informs: cockroachdb#112629
Release note: None
@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 3, 2023

Build succeeded:

@craig craig bot merged commit 694861a into cockroachdb:master Nov 3, 2023
3 checks passed
@RaduBerinde RaduBerinde deleted the version-cleanup branch November 3, 2023 13:55
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