Skip to content

Commit

Permalink
testserver: fix tenant-client cert arguments
Browse files Browse the repository at this point in the history
Since cockroachdb/cockroach#71248 the server
address must be passed in as a positional argument.

Technically, the version check makes cockroach-go tenant servers not
work for commits between a0c04c620ddb67cf44265eaef61bcd38c13e4fe7 and
d7569dae28d405437f5af670346d45c2d6deb42a, but I think this is an
acceptable breakage since those are unreleased commits.
  • Loading branch information
rafiss authored and martingallagher committed Jan 19, 2022
1 parent 075f7b5 commit 5148885
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions testserver/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/cockroachdb/cockroach-go/v2/testserver/version"
"log"
"net"
"net/url"
Expand Down Expand Up @@ -74,19 +75,16 @@ func (ts *testServerImpl) NewTenantServer(proxy bool) (TestServer, error) {
certsDir := filepath.Join(ts.baseDir, "certs")
if ts.serverArgs.secure {
secureFlag = "--certs-dir=" + certsDir
certArgs := []string{
secureFlag,
"--ca-key=" + filepath.Join(certsDir, "ca.key"),
// Create tenant client certificate.
certArgs := []string{"mt", "cert", "create-tenant-client", fmt.Sprint(tenantID)}
if ts.version.AtLeast(version.MustParse("v22.1.0-alpha")) {
certArgs = append(certArgs, "127.0.0.1", "[::1]", "localhost", "*.local")
}
for _, args := range [][]string{
// Create tenant client certificate.
{"mt", "cert", "create-tenant-client", fmt.Sprint(tenantID)},
} {
createCertCmd := exec.Command(cockroachBinary, append(args, certArgs...)...)
log.Printf("%s executing: %s", tenantserverMessagePrefix, createCertCmd)
if err := createCertCmd.Run(); err != nil {
return nil, fmt.Errorf("%s command %s failed: %w", tenantserverMessagePrefix, createCertCmd, err)
}
certArgs = append(certArgs, secureFlag, "--ca-key=" + filepath.Join(certsDir, "ca.key"))
createCertCmd := exec.Command(cockroachBinary, certArgs...)
log.Printf("%s executing: %s", tenantserverMessagePrefix, createCertCmd)
if err := createCertCmd.Run(); err != nil {
return nil, fmt.Errorf("%s command %s failed: %w", tenantserverMessagePrefix, createCertCmd, err)
}
}
// Create a new tenant.
Expand Down

0 comments on commit 5148885

Please sign in to comment.