Skip to content

Commit 8f5f0e6

Browse files
committed
roachprod: default --insecure to true
As of [1], [2], `roachprod` defaulted to "secure" mode to keep it in one-to-one correspondence with `roachtest`. However, upon further reflection (see an internal thread [3]), "secure mode" adds an unnecessary friction. As of this change, `roachprod` now defaults to "insecure" mode while `roachtest` _continues_ to default to "secure". Further, `drtprod` also continues to default to "secure" mode. [1] #123593 [2] #123826 [3] https://cockroachlabs.slack.com/archives/C023S0V4YEB/p1748888536180379?thread_ts=1724452649.312729&cid=C023S0V4YEB Epic: none Release note: None
1 parent 8f3ba4a commit 8f5f0e6

File tree

10 files changed

+92
-118
lines changed

10 files changed

+92
-118
lines changed

pkg/cmd/drtprod/cli/commands/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
deps = [
1212
"//pkg/build",
1313
"//pkg/cmd/drtprod/helpers",
14+
"//pkg/cmd/roachprod/cli",
1415
"//pkg/roachprod",
1516
"//pkg/roachprod/config",
1617
"//pkg/roachprod/install",

pkg/cmd/drtprod/cli/commands/yamlprocessor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"time"
1919

2020
"github.com/cockroachdb/cockroach/pkg/cmd/drtprod/helpers"
21+
"github.com/cockroachdb/cockroach/pkg/cmd/roachprod/cli"
2122
"github.com/cockroachdb/cockroach/pkg/roachprod"
2223
"github.com/cockroachdb/cockroach/pkg/roachprod/config"
2324
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
@@ -64,7 +65,7 @@ You can also specify the rollback commands in case of a step failure.
6465
`,
6566
Args: cobra.ExactArgs(1),
6667
// Wraps the command execution with additional error handling
67-
Run: helpers.Wrap(func(cmd *cobra.Command, args []string) (retErr error) {
68+
Run: cli.Wrap(func(cmd *cobra.Command, args []string) (retErr error) {
6869
_, err := exec.LookPath("drtprod")
6970
if err != nil {
7071
// drtprod is needed in the path to run yaml commands

pkg/cmd/drtprod/cli/handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func init() {
4545

4646
// Initialize sets up the environment and initializes the command-line interface.
4747
func Initialize(ctx context.Context) {
48+
// Apply our flag defaults.
49+
cli.UpdateFlagDefaults()
4850
// Disable command sorting in Cobra (command-line parser).
4951
cobra.EnableCommandSorting = false
5052

pkg/cmd/drtprod/helpers/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ go_library(
55
srcs = ["utils.go"],
66
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/drtprod/helpers",
77
visibility = ["//visibility:public"],
8-
deps = [
9-
"//pkg/roachprod/errors",
10-
"@com_github_spf13_cobra//:cobra",
11-
],
128
)

pkg/cmd/drtprod/helpers/utils.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,9 @@ import (
99
"bufio"
1010
"context"
1111
"fmt"
12-
"os"
1312
"os/exec"
14-
15-
rperrors "github.com/cockroachdb/cockroach/pkg/roachprod/errors"
16-
"github.com/spf13/cobra"
1713
)
1814

19-
// Wrap provide `cobra.Command` functions with a standard return code handler.
20-
// Exit codes come from rperrors.Error.ExitCode().
21-
//
22-
// If the wrapped error tree of an error does not contain an instance of
23-
// rperrors.Error, the error will automatically be wrapped with
24-
// rperrors.Unclassified.
25-
func Wrap(f func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) {
26-
return func(cmd *cobra.Command, args []string) {
27-
var err error
28-
err = f(cmd, args)
29-
if err != nil {
30-
drtprodError, ok := rperrors.AsError(err)
31-
if !ok {
32-
drtprodError = rperrors.Unclassified{Err: err}
33-
err = drtprodError
34-
}
35-
36-
cmd.Printf("Error: %+v\n", err)
37-
38-
os.Exit(drtprodError.ExitCode())
39-
}
40-
}
41-
}
42-
4315
// ExecuteCmdWithPrefix runs a shell command with the given arguments and streams the output.
4416
// it also adds the specified prefixes
4517
func ExecuteCmdWithPrefix(ctx context.Context, logPrefix string, cmd string, args ...string) error {

0 commit comments

Comments
 (0)