Skip to content

Commit

Permalink
roachprod: use 'lb' to denote load balancer
Browse files Browse the repository at this point in the history
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
  • Loading branch information
herkolategan committed May 7, 2024
1 parent 0377fc2 commit dbd590f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions pkg/cmd/roachprod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,13 @@ var pgurlCmd = &cobra.Command{
Short: "generate pgurls for the nodes in a cluster",
Long: `Generate pgurls for the nodes in a cluster.
The command generates postgres urls for the specified nodes in a cluster.
Both the nodes or a load balancer can be specified as the target of the pgurl.
Examples of <cluster>:
cluster-name:1-3
cluster-name:lb
--auth-mode specifies the method of authentication unless --insecure is passed.
Defaults to root if not passed. Available auth-modes are:
Expand Down
12 changes: 6 additions & 6 deletions pkg/roachprod/install/expander.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,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]+)?}`)
var pgHostRe = regexp.MustCompile(`{pghost(:[-,0-9]+|:(?i)lb)?(:[a-z0-9\-]+)?(:[0-9]+)?}`)
var pgPortRe = regexp.MustCompile(`{pgport(:[-,0-9]+)?(:[a-z0-9\-]+)?(:[0-9]+)?}`)
var uiPortRe = regexp.MustCompile(`{uiport(:[-,0-9]+)}`)
var storeDirRe = regexp.MustCompile(`{store-dir(:[0-9]+)?}`)
Expand Down Expand Up @@ -158,8 +158,8 @@ func (e *expander) maybeExpandPgURL(
if err != nil {
return "", false, err
}
switch m[1] {
case ":L":
switch strings.ToLower(m[1]) {
case ":lb":
url, err := c.loadBalancerURL(ctx, l, virtualClusterName, sqlInstance, DefaultAuthMode)
return url, url != "", err
default:
Expand Down Expand Up @@ -187,8 +187,8 @@ func (e *expander) maybeExpandPgHost(
return "", false, err
}

switch m[1] {
case ":L":
switch strings.ToLower(m[1]) {
case ":lb":
services, err := c.DiscoverServices(ctx, virtualClusterName, ServiceTypeSQL, ServiceInstancePredicate(sqlInstance))
if err != nil {
return "", false, err
Expand Down
1 change: 1 addition & 0 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ func PgURL(

nodes := c.TargetNodes()
ips := make([]string, len(nodes))

if opts.External {
for i := 0; i < len(nodes); i++ {
ips[i] = c.VMs[nodes[i]-1].PublicIP
Expand Down

0 comments on commit dbd590f

Please sign in to comment.