Skip to content

Commit

Permalink
flags: mark --insecure as deprecated
Browse files Browse the repository at this point in the history
Release note (cli change): The command-line `--insecure` has been
marked as deprecated. See https://go.crdb.dev/issue/53404 for details.
The flag will be removed in a later version in a staged fashion:
first, additional security mechanisms will be added to enable more
flexible deployments which were previously done using `--insecure`;
then the flaf will be removed from server commands, then finally in a
later version also from client commands.
  • Loading branch information
knz committed Aug 25, 2020
1 parent feea7df commit 8f30eb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
"github.com/cockroachdb/cockroach/pkg/util/humanizeutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logflags"
Expand Down Expand Up @@ -390,6 +391,8 @@ func init() {
// Use a separate variable to store the value of ServerInsecure.
// We share the default with the ClientInsecure flag.
boolFlag(f, &startCtx.serverInsecure, cliflags.ServerInsecure)
_ = f.MarkDeprecated(cliflags.ServerInsecure.Name, "it will be removed in a subsequent release.\n"+
"For details, see: "+unimplemented.MakeURL(53404))

// Enable/disable various external storage endpoints.
boolFlag(f, &serverCfg.ExternalIODirConfig.DisableHTTP, cliflags.ExternalIODisableHTTP)
Expand Down Expand Up @@ -555,6 +558,8 @@ func init() {
_ = f.MarkHidden(cliflags.ClientPort.Name)

boolFlag(f, &baseCfg.Insecure, cliflags.ClientInsecure)
_ = f.MarkDeprecated(cliflags.ServerInsecure.Name, "it will be removed in a subsequent release.\n"+
"For details, see: "+unimplemented.MakeURL(53404))

// Certificate flags.
stringFlag(f, &baseCfg.SSLCertsDir, cliflags.CertsDir)
Expand Down Expand Up @@ -735,6 +740,8 @@ func init() {
varFlag(f, demoNodeSQLMemSizeValue, cliflags.DemoNodeSQLMemSize)
varFlag(f, demoNodeCacheSizeValue, cliflags.DemoNodeCacheSize)
boolFlag(f, &demoCtx.insecure, cliflags.ClientInsecure)
_ = f.MarkDeprecated(cliflags.ServerInsecure.Name, "it will be removed in a subsequent release.\n"+
"For details, see: "+unimplemented.MakeURL(53404))
boolFlag(f, &demoCtx.disableLicenseAcquisition, cliflags.DemoNoLicense)
// Mark the --global flag as hidden until we investigate it more.
boolFlag(f, &demoCtx.simulateLatency, cliflags.Global)
Expand Down Expand Up @@ -799,6 +806,9 @@ func init() {
// (which is a PreRun for this command):
_ = extraServerFlagInit // guru assignment
boolFlag(f, &startCtx.serverInsecure, cliflags.ServerInsecure)
_ = f.MarkDeprecated(cliflags.ServerInsecure.Name, "it will be removed in a subsequent release.\n"+
"For details, see: "+unimplemented.MakeURL(53404))

stringFlag(f, &startCtx.serverSSLCertsDir, cliflags.ServerCertsDir)
// NB: this also gets PreRun treatment via extraServerFlagInit to populate BaseCfg.SQLAddr.
varFlag(f, addrSetter{&serverSQLAddr, &serverSQLPort}, cliflags.ListenSQLAddr)
Expand Down
9 changes: 8 additions & 1 deletion pkg/cmd/roachtest/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ func runCLINodeStatus(ctx context.Context, t *test, c *cluster) {

lastWords := func(s string) []string {
var result []string
for _, line := range strings.Split(s, "\n") {
lines := strings.Split(s, "\n")
// v20.1 introduces a deprecation notice for --insecure. Skip over it.
// TODO(knz): Remove this when --insecure is dropped.
// See: https://github.com/cockroachdb/cockroach/issues/53404
if len(lines) > 0 && strings.HasPrefix(lines[0], "Flag --insecure has been deprecated") {
lines = lines[2:]
}
for _, line := range lines {
words := strings.Fields(line)
if n := len(words); n > 0 {
result = append(result, words[n-2]+" "+words[n-1])
Expand Down

0 comments on commit 8f30eb1

Please sign in to comment.