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

roachprod: introduce Node type #72957

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

RaduBerinde
Copy link
Member

There is a lot of confusion in the code around node "indexes".
Sometimes these are a (0-based) index in the target list of nodes,
sometimes they are a (1-based) node ID. This makes the code harder to
follow and more error-prone (in fact, there are a couple of places
where we convert from one to the other incorrectly).

This change introduces the types Node and Nodes and switches code
to use Node (rather than the 0-based index) whenever possible. This
enlists the compiler's help, as it is no longer legal to implicitly
convert from one to the other.

Release note: None

@RaduBerinde RaduBerinde requested a review from a team as a code owner November 18, 2021 23:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

There is a lot of confusion in the code around node "indexes".
Sometimes these are a (0-based) index in the target list of nodes,
sometimes they are a (1-based) node ID. This makes the code harder to
follow and more error-prone (in fact, there are a couple of places
where we convert from one to the other incorrectly).

This change introduces the types `Node` and `Nodes` and switches code
to use `Node` (rather than the 0-based index) whenever possible. This
enlists the compiler's help, as it is no longer legal to implicitly
convert from one to the other.

Release note: None
Copy link
Member

@rail rail left a comment

Choose a reason for hiding this comment

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

Love it! So much easier to read when you don't need to figure out what int means in a particular context. There is a small typo, after fixing which this can be merged.

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @healthy-pod and @RaduBerinde)


pkg/roachprod/install/nodes.go, line 26 at r1 (raw file):

type Node int

// Node is a list of nodes. In most cases, this is a set and the values are

Typo: s/Node/Nodes/

@RaduBerinde RaduBerinde force-pushed the roachprod-advertise-addr branch from 86a1f31 to e482fc8 Compare November 19, 2021 22:36
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.

TFTR!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @healthy-pod and @rail)


pkg/roachprod/install/nodes.go, line 26 at r1 (raw file):

Previously, rail (Rail Aliiev) wrote…

Typo: s/Node/Nodes/

Done.

@craig
Copy link
Contributor

craig bot commented Nov 19, 2021

Build succeeded:

@craig craig bot merged commit 429fee0 into cockroachdb:master Nov 19, 2021
@RaduBerinde RaduBerinde deleted the roachprod-advertise-addr branch November 21, 2021 11:48
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.

3 participants