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: load balancer from pgurl command #123206

Merged

Conversation

herkolategan
Copy link
Collaborator

@herkolategan herkolategan commented Apr 29, 2024

Previously, the load balancer IP or URL can only be retrieved using the expanders. This change adds the ability to also get the URL from the roachprod pgurl command by using the lb node selector similar to how it is done with expansion.

Epic: None
Release Note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@herkolategan herkolategan marked this pull request as ready for review May 1, 2024 09:49
@herkolategan herkolategan requested a review from a team as a code owner May 1, 2024 09:49
@herkolategan herkolategan requested review from DarrylWong and renatolabs and removed request for a team May 1, 2024 09:49
if s == "all" {
// "L" is a special value that also returns all nodes, but implies a load
// balancer should be used when applicable.
if s == "all" || s == "L" {
Copy link
Member

Choose a reason for hiding this comment

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

Why not LB? L doesn't seem like a memorable mnemonic unlike all. Should it also be case-insensitive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I matched this to how the expanders also select the load balancer vs. node IPs. I can update both. I'll maybe add it to the command help as well to make it clear as an option.

@herkolategan herkolategan force-pushed the hbl/roachprod-lb-pgurl-command branch from ea28ee9 to c31dbbe Compare May 3, 2024 13:04
@srosenberg srosenberg self-requested a review May 3, 2024 13:46
Copy link
Member

@srosenberg srosenberg 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 switching to the lb mnemonic; I promise it will be easier to remember (for me) :) The rest looks good, but do update the commit msg. to replace L with lb.

@@ -44,7 +44,9 @@ func ListNodes(s string, numNodesInCluster int) (Nodes, error) {
return nil, errors.AssertionFailedf("invalid number of nodes %d", numNodesInCluster)
}

if s == "all" {
// "lb" is a special value that also returns all nodes, but implies a load
// balancer should be used when applicable.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why "when applicable"? I don't see logic below to handle the case where a load balancer is not available (would we want that?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, I'll update the comment to be more concise.

@@ -184,6 +184,13 @@ func newCluster(
return c, nil
}

// preferLoadBalancer determines if the node selector section in the cluster
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this is a similar point, but prefer suggests that actually returning a LB IP is optional, but it seems we return an error below if we can't find a LB.

I actually prefer this semantics (error returned if LB requested but doesn't exist) unless there's strong reason to provide a fallback. In that case, maybe requestedLoadBalancer might be a better name.

@@ -22,8 +22,8 @@ import (
)

var parameterRe = regexp.MustCompile(`{[^{}]*}`)
var pgURLRe = regexp.MustCompile(`{pgurl(:[-,0-9]+|:L)?(:[a-z0-9\-]+)?(:[0-9]+)?}`)
var pgHostRe = regexp.MustCompile(`{pghost(:[-,0-9]+|:L)?(:[a-z0-9\-]+)?(:[0-9]+)?}`)
var pgURLRe = regexp.MustCompile(`{pgurl(:[-,0-9]+|:(?i)lb)?(:[a-z0-9\-]+)?(:[0-9]+)?}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

At some point it would be nice to document these with examples, these regexes are getting complicated 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, these are becoming a bit over-encumbered.

@herkolategan herkolategan force-pushed the hbl/roachprod-lb-pgurl-command branch from c31dbbe to 81d5a73 Compare May 7, 2024 08:06
Previously, the load balancer IP or URL can only be retrieved using the
expanders. This change adds the ability to also get the URL from the `roachprod`
pgurl command by using the `lb` node selector similar to how it is done with
expansion.

Epic: None
Release Note: None
@herkolategan herkolategan force-pushed the hbl/roachprod-lb-pgurl-command branch 2 times, most recently from 613cb2b to 390d1fc Compare May 7, 2024 13:37
Previously, `L` was used in the `roachprod` expanders and other place to select
load balancers. This change updates it to `LB` or `lb` to be more explicit. The
help for commands have also been updated to inform the user that an option
exists to select a load balancer.

Epic: None
Release Note: None
@herkolategan herkolategan force-pushed the hbl/roachprod-lb-pgurl-command branch from 390d1fc to dbd590f Compare May 7, 2024 15:37
@herkolategan
Copy link
Collaborator Author

TFTRs!

bors r=srosenberg,renatolabs

@craig craig bot merged commit bd9a7d3 into cockroachdb:master May 7, 2024
20 of 22 checks passed
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