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 postgres URL #121831

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

herkolategan
Copy link
Collaborator

Add "L" to the node expansion in roachprod (e.g., test-cluster:L vs.
test-cluster:1). This allows users to pass "L" instead of a node range /
number. It will return the load balancer IP or postgres URL (depending on the
expander used) and will enable workload and other utilities to target the load
balancer IP rather than a specific node.

Epic: None
Release Note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@herkolategan herkolategan changed the title roachprod: resolve load balancer roachprod: load balancer postgres URL Apr 5, 2024
@herkolategan herkolategan marked this pull request as ready for review April 12, 2024 10:30
@herkolategan herkolategan requested a review from a team as a code owner April 12, 2024 10:30
@herkolategan herkolategan requested review from DarrylWong and renatolabs and removed request for a team April 12, 2024 10:30
Copy link
Contributor

@DarrylWong DarrylWong left a comment

Choose a reason for hiding this comment

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

LGTM!

return &a, nil
}
}
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we just return a "load balancer not found" error here so that way callers of this function don't need to manually check if address is nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! done.

e.pgHosts, err = c.pghosts(ctx, l, allNodes(len(c.VMs)))
switch m[1] {
case ":L":
addresses, err := c.ListLoadBalancers(l)
Copy link
Contributor

@renatolabs renatolabs Apr 19, 2024

Choose a reason for hiding this comment

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

Hrmm, don't the semantics of pghost get a bit murky with this implementation of pghost?

Say I create a load balancer for system and tenant in the cluster. What does it mean to say {pghost:L} in that case? Not sure if the List* functions are deterministic (w.r.t. ordering of LBs), in which case it could get even more confusing.

Maybe the "two load balancer" scenario is not common enough. It probably wouldn't hurt if pghost took a virtual cluster name parameter as well.

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, this won't work well for multiple load balancers. Adding a tenant group to this.

if err != nil || address == nil {
return "", err
}
loadBalancerURL := c.NodeURL(address.IP, address.Port, virtualClusterName, serviceMode, AuthRootCert)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we take auth as parameter? I know it will complicate matters for the expanders, but assuming root doesn't seem right either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch, yes we should pass auth. Done. Also updated to use the same auth as the other expanders.

@herkolategan herkolategan force-pushed the hbl/roachprod-lb-expanders branch 2 times, most recently from baf4be0 to b2bd159 Compare April 24, 2024 11:46
Add the ability to find a load balancer given the service port it serves. If no
port (0) is specified the first load balancer found will be returned.

Epic: None
Release Note: None
Add ability to get the postgres URL for a load balancer given a service.

Epic: None
Release Note: None
Add "L" to the node expansion in `roachprod` (e.g., `test-cluster:L` vs.
`test-cluster:1`). This allows users to pass "L" instead of a node range /
number. It will return the load balancer IP or postgres URL (depending on the
expander used) and will enable `workload` and other utilities to target the load
balancer IP rather than a specific node.

Epic: None
Release Note: None
Epic: None
Release Note: None
@herkolategan herkolategan force-pushed the hbl/roachprod-lb-expanders branch from b2bd159 to 8cb12bd Compare April 24, 2024 11:55
@herkolategan
Copy link
Collaborator Author

TFTR!

bors r=DarrylWong

@craig craig bot merged commit 4634d3f into cockroachdb:master Apr 24, 2024
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.

4 participants