From 3bde92a5b818a17431ebae6f16d1137bdc2cc419 Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Wed, 14 Dec 2022 11:37:26 -0500 Subject: [PATCH] cli,cliccl: move mt commands to cliccl Part of #91714 Epic: none Release note: None --- pkg/ccl/cliccl/BUILD.bazel | 11 +++++ pkg/ccl/cliccl/context.go | 51 ++++++++++++++++++++ pkg/ccl/cliccl/flags.go | 45 +++++++++++++++++ pkg/ccl/cliccl/mt.go | 18 +++++++ pkg/{cli => ccl/cliccl}/mt_proxy.go | 29 ++++------- pkg/{cli => ccl/cliccl}/mt_test_directory.go | 19 +++----- pkg/cli/BUILD.bazel | 4 -- pkg/cli/context.go | 34 ------------- pkg/cli/debug_synctest.go | 2 +- pkg/cli/flags.go | 33 +++---------- pkg/cli/mt.go | 34 ++++++++++--- pkg/cli/start.go | 15 ++++-- pkg/cli/start_unix.go | 4 +- pkg/cli/start_windows.go | 4 +- 14 files changed, 191 insertions(+), 112 deletions(-) create mode 100644 pkg/ccl/cliccl/context.go create mode 100644 pkg/ccl/cliccl/flags.go create mode 100644 pkg/ccl/cliccl/mt.go rename pkg/{cli => ccl/cliccl}/mt_proxy.go (84%) rename pkg/{cli => ccl/cliccl}/mt_test_directory.go (76%) diff --git a/pkg/ccl/cliccl/BUILD.bazel b/pkg/ccl/cliccl/BUILD.bazel index 3b6dcd491159..6806899f470e 100644 --- a/pkg/ccl/cliccl/BUILD.bazel +++ b/pkg/ccl/cliccl/BUILD.bazel @@ -5,9 +5,14 @@ go_library( name = "cliccl", srcs = [ "cliccl.go", + "context.go", "debug.go", "demo.go", "ear.go", + "flags.go", + "mt.go", + "mt_proxy.go", + "mt_test_directory.go", "start.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/ccl/cliccl", @@ -16,21 +21,27 @@ go_library( "//pkg/base", "//pkg/ccl/baseccl", "//pkg/ccl/cliccl/cliflagsccl", + "//pkg/ccl/sqlproxyccl", + "//pkg/ccl/sqlproxyccl/tenantdirsvr", "//pkg/ccl/storageccl/engineccl/enginepbccl", "//pkg/ccl/utilccl", "//pkg/ccl/workloadccl/cliccl", "//pkg/cli", "//pkg/cli/clierrorplus", "//pkg/cli/cliflagcfg", + "//pkg/cli/cliflags", "//pkg/cli/democluster", "//pkg/storage", "//pkg/storage/enginepb", + "//pkg/util/log", + "//pkg/util/log/severity", "//pkg/util/protoutil", "//pkg/util/stop", "//pkg/util/timeutil", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//oserror", "@com_github_cockroachdb_pebble//vfs", + "@com_github_cockroachdb_redact//:redact", "@com_github_spf13_cobra//:cobra", ], ) diff --git a/pkg/ccl/cliccl/context.go b/pkg/ccl/cliccl/context.go new file mode 100644 index 000000000000..a00834413fe5 --- /dev/null +++ b/pkg/ccl/cliccl/context.go @@ -0,0 +1,51 @@ +// Copyright 2022 The Cockroach Authors. +// +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt + +package cliccl + +import ( + "time" + + "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl" +) + +func init() { + setProxyContextDefaults() + setTestDirectorySvrContextDefaults() +} + +// proxyContext captures the command-line parameters of the `mt start-proxy` command. +var proxyContext sqlproxyccl.ProxyOptions + +func setProxyContextDefaults() { + proxyContext.Denylist = "" + proxyContext.ListenAddr = "127.0.0.1:46257" + proxyContext.ListenCert = "" + proxyContext.ListenKey = "" + proxyContext.MetricsAddress = "0.0.0.0:8080" + proxyContext.RoutingRule = "" + proxyContext.DirectoryAddr = "" + proxyContext.SkipVerify = false + proxyContext.Insecure = false + proxyContext.RatelimitBaseDelay = 50 * time.Millisecond + proxyContext.ValidateAccessInterval = 30 * time.Second + proxyContext.PollConfigInterval = 30 * time.Second + proxyContext.ThrottleBaseDelay = time.Second + proxyContext.DisableConnectionRebalancing = false +} + +var testDirectorySvrContext struct { + port int + certsDir string + kvAddrs string + tenantBaseDir string +} + +func setTestDirectorySvrContextDefaults() { + testDirectorySvrContext.port = 36257 +} diff --git a/pkg/ccl/cliccl/flags.go b/pkg/ccl/cliccl/flags.go new file mode 100644 index 000000000000..8cfed934e5be --- /dev/null +++ b/pkg/ccl/cliccl/flags.go @@ -0,0 +1,45 @@ +// Copyright 2022 The Cockroach Authors. +// +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt + +package cliccl + +import ( + "github.com/cockroachdb/cockroach/pkg/cli" + "github.com/cockroachdb/cockroach/pkg/cli/cliflagcfg" + "github.com/cockroachdb/cockroach/pkg/cli/cliflags" +) + +func init() { + // Multi-tenancy proxy command flags. + { + f := mtStartSQLProxyCmd.Flags() + cliflagcfg.StringFlag(f, &proxyContext.Denylist, cliflags.DenyList) + cliflagcfg.StringFlag(f, &proxyContext.ListenAddr, cliflags.ProxyListenAddr) + cliflagcfg.StringFlag(f, &proxyContext.ListenCert, cliflags.ListenCert) + cliflagcfg.StringFlag(f, &proxyContext.ListenKey, cliflags.ListenKey) + cliflagcfg.StringFlag(f, &proxyContext.MetricsAddress, cliflags.ListenMetrics) + cliflagcfg.StringFlag(f, &proxyContext.RoutingRule, cliflags.RoutingRule) + cliflagcfg.StringFlag(f, &proxyContext.DirectoryAddr, cliflags.DirectoryAddr) + cliflagcfg.BoolFlag(f, &proxyContext.SkipVerify, cliflags.SkipVerify) + cliflagcfg.BoolFlag(f, &proxyContext.Insecure, cliflags.InsecureBackend) + cliflagcfg.DurationFlag(f, &proxyContext.ValidateAccessInterval, cliflags.ValidateAccessInterval) + cliflagcfg.DurationFlag(f, &proxyContext.PollConfigInterval, cliflags.PollConfigInterval) + cliflagcfg.DurationFlag(f, &proxyContext.ThrottleBaseDelay, cliflags.ThrottleBaseDelay) + cliflagcfg.BoolFlag(f, &proxyContext.DisableConnectionRebalancing, cliflags.DisableConnectionRebalancing) + } + + // Multi-tenancy test directory command flags. + cli.RegisterFlags(func() { + f := mtTestDirectorySvr.Flags() + cliflagcfg.IntFlag(f, &testDirectorySvrContext.port, cliflags.TestDirectoryListenPort) + cliflagcfg.StringFlag(f, &testDirectorySvrContext.certsDir, cliflags.TestDirectoryTenantCertsDir) + cliflagcfg.StringFlag(f, &testDirectorySvrContext.tenantBaseDir, cliflags.TestDirectoryTenantBaseDir) + // Use StringFlagDepth to avoid conflicting with the already registered KVAddrs env var. + cliflagcfg.StringFlagDepth(1, f, &testDirectorySvrContext.kvAddrs, cliflags.KVAddrs) + }) +} diff --git a/pkg/ccl/cliccl/mt.go b/pkg/ccl/cliccl/mt.go new file mode 100644 index 000000000000..5232b35be285 --- /dev/null +++ b/pkg/ccl/cliccl/mt.go @@ -0,0 +1,18 @@ +// Copyright 2022 The Cockroach Authors. +// +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt + +package cliccl + +import "github.com/cockroachdb/cockroach/pkg/cli" + +func init() { + cli.MTCmd.AddCommand(mtStartSQLProxyCmd) + cli.RegisterCommandWithCustomLogging(mtStartSQLProxyCmd) + cli.MTCmd.AddCommand(mtTestDirectorySvr) + cli.RegisterCommandWithCustomLogging(mtTestDirectorySvr) +} diff --git a/pkg/cli/mt_proxy.go b/pkg/ccl/cliccl/mt_proxy.go similarity index 84% rename from pkg/cli/mt_proxy.go rename to pkg/ccl/cliccl/mt_proxy.go index 2519200014cc..c6d905b77589 100644 --- a/pkg/cli/mt_proxy.go +++ b/pkg/ccl/cliccl/mt_proxy.go @@ -1,14 +1,12 @@ -// Copyright 2021 The Cockroach Authors. +// Copyright 2022 The Cockroach Authors. // -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at // -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt -package cli +package cliccl import ( "context" @@ -19,6 +17,7 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl" + "github.com/cockroachdb/cockroach/pkg/cli" "github.com/cockroachdb/cockroach/pkg/cli/clierrorplus" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/log/severity" @@ -97,18 +96,10 @@ func runStartSQLProxy(cmd *cobra.Command, args []string) (returnErr error) { } func initLogging(cmd *cobra.Command) (ctx context.Context, stopper *stop.Stopper, err error) { - // Remove the default store, which avoids using it to set up logging. - // Instead, we'll default to logging to stderr unless --log-dir is - // specified. This makes sense since the standalone SQL server is - // at the time of writing stateless and may not be provisioned with - // suitable storage. - serverCfg.Stores.Specs = nil - serverCfg.ClusterName = "" - ctx = context.Background() - stopper, err = setupAndInitializeLoggingAndProfiling(ctx, cmd, false /* isServerCmd */) + stopper, err = cli.ClearStoresAndSetupLoggingForMTCommands(cmd, ctx) if err != nil { - return + return ctx, nil, err } ctx, _ = stopper.WithCancelOnQuiesce(ctx) return ctx, stopper, err @@ -123,7 +114,7 @@ func waitForSignals( ) (returnErr error) { // Need to alias the signals if this has to run on non-unix OSes too. signalCh := make(chan os.Signal, 1) - signal.Notify(signalCh, drainSignals...) + signal.Notify(signalCh, cli.DrainSignals...) select { case err := <-errChan: diff --git a/pkg/cli/mt_test_directory.go b/pkg/ccl/cliccl/mt_test_directory.go similarity index 76% rename from pkg/cli/mt_test_directory.go rename to pkg/ccl/cliccl/mt_test_directory.go index 4a26640ac868..c44da186728a 100644 --- a/pkg/cli/mt_test_directory.go +++ b/pkg/ccl/cliccl/mt_test_directory.go @@ -1,14 +1,12 @@ -// Copyright 2021 The Cockroach Authors. +// Copyright 2022 The Cockroach Authors. // -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at // -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt -package cli +package cliccl import ( "context" @@ -16,6 +14,7 @@ import ( "net" "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/tenantdirsvr" + "github.com/cockroachdb/cockroach/pkg/cli" "github.com/cockroachdb/cockroach/pkg/cli/clierrorplus" "github.com/cockroachdb/cockroach/pkg/util/stop" "github.com/spf13/cobra" @@ -48,9 +47,7 @@ test-directory command will always add the following arguments (in that order): func runDirectorySvr(cmd *cobra.Command, args []string) (returnErr error) { ctx := context.Background() - serverCfg.Stores.Specs = nil - - stopper, err := setupAndInitializeLoggingAndProfiling(ctx, cmd, false /* isServerCmd */) + stopper, err := cli.ClearStoresAndSetupLoggingForMTCommands(cmd, ctx) if err != nil { return err } diff --git a/pkg/cli/BUILD.bazel b/pkg/cli/BUILD.bazel index 01270a147ebc..7855bda0aa5a 100644 --- a/pkg/cli/BUILD.bazel +++ b/pkg/cli/BUILD.bazel @@ -42,9 +42,7 @@ go_library( "log_flags.go", "mt.go", "mt_cert.go", - "mt_proxy.go", "mt_start_sql.go", - "mt_test_directory.go", "node.go", "nodelocal.go", "prefixer.go", @@ -101,8 +99,6 @@ go_library( deps = [ "//pkg/base", "//pkg/build", - "//pkg/ccl/sqlproxyccl", - "//pkg/ccl/sqlproxyccl/tenantdirsvr", "//pkg/cli/clicfg", "//pkg/cli/clientflags", "//pkg/cli/clienturl", diff --git a/pkg/cli/context.go b/pkg/cli/context.go index 33f25de47b17..aa5b414faec5 100644 --- a/pkg/cli/context.go +++ b/pkg/cli/context.go @@ -18,7 +18,6 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/base" - "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl" "github.com/cockroachdb/cockroach/pkg/cli/clicfg" "github.com/cockroachdb/cockroach/pkg/cli/clisqlcfg" "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" @@ -64,8 +63,6 @@ func initCLIDefaults() { setStmtDiagContextDefaults() setAuthContextDefaults() setImportContextDefaults() - setProxyContextDefaults() - setTestDirectorySvrContextDefaults() setUserfileContextDefaults() setCertContextDefaults() setDebugRecoverContextDefaults() @@ -663,37 +660,6 @@ func setImportContextDefaults() { importCtx.rowLimit = 0 } -// proxyContext captures the command-line parameters of the `mt start-proxy` command. -var proxyContext sqlproxyccl.ProxyOptions - -func setProxyContextDefaults() { - proxyContext.Denylist = "" - proxyContext.ListenAddr = "127.0.0.1:46257" - proxyContext.ListenCert = "" - proxyContext.ListenKey = "" - proxyContext.MetricsAddress = "0.0.0.0:8080" - proxyContext.RoutingRule = "" - proxyContext.DirectoryAddr = "" - proxyContext.SkipVerify = false - proxyContext.Insecure = false - proxyContext.RatelimitBaseDelay = 50 * time.Millisecond - proxyContext.ValidateAccessInterval = 30 * time.Second - proxyContext.PollConfigInterval = 30 * time.Second - proxyContext.ThrottleBaseDelay = time.Second - proxyContext.DisableConnectionRebalancing = false -} - -var testDirectorySvrContext struct { - port int - certsDir string - kvAddrs string - tenantBaseDir string -} - -func setTestDirectorySvrContextDefaults() { - testDirectorySvrContext.port = 36257 -} - // userfileCtx captures the command-line parameters of the // `userfile` command. // See below for defaults. diff --git a/pkg/cli/debug_synctest.go b/pkg/cli/debug_synctest.go index e263c2de9159..4ca47b1ff35c 100644 --- a/pkg/cli/debug_synctest.go +++ b/pkg/cli/debug_synctest.go @@ -174,7 +174,7 @@ func runSyncer( } ch := make(chan os.Signal, 1) - signal.Notify(ch, drainSignals...) + signal.Notify(ch, DrainSignals...) write := func() (_ int64, err error) { defer func() { diff --git a/pkg/cli/flags.go b/pkg/cli/flags.go index 651ae1a2643f..dddad080e979 100644 --- a/pkg/cli/flags.go +++ b/pkg/cli/flags.go @@ -914,33 +914,6 @@ func init() { } } - // Multi-tenancy proxy command flags. - { - f := mtStartSQLProxyCmd.Flags() - cliflagcfg.StringFlag(f, &proxyContext.Denylist, cliflags.DenyList) - cliflagcfg.StringFlag(f, &proxyContext.ListenAddr, cliflags.ProxyListenAddr) - cliflagcfg.StringFlag(f, &proxyContext.ListenCert, cliflags.ListenCert) - cliflagcfg.StringFlag(f, &proxyContext.ListenKey, cliflags.ListenKey) - cliflagcfg.StringFlag(f, &proxyContext.MetricsAddress, cliflags.ListenMetrics) - cliflagcfg.StringFlag(f, &proxyContext.RoutingRule, cliflags.RoutingRule) - cliflagcfg.StringFlag(f, &proxyContext.DirectoryAddr, cliflags.DirectoryAddr) - cliflagcfg.BoolFlag(f, &proxyContext.SkipVerify, cliflags.SkipVerify) - cliflagcfg.BoolFlag(f, &proxyContext.Insecure, cliflags.InsecureBackend) - cliflagcfg.DurationFlag(f, &proxyContext.ValidateAccessInterval, cliflags.ValidateAccessInterval) - cliflagcfg.DurationFlag(f, &proxyContext.PollConfigInterval, cliflags.PollConfigInterval) - cliflagcfg.DurationFlag(f, &proxyContext.ThrottleBaseDelay, cliflags.ThrottleBaseDelay) - cliflagcfg.BoolFlag(f, &proxyContext.DisableConnectionRebalancing, cliflags.DisableConnectionRebalancing) - } - - // Multi-tenancy test directory command flags. - { - f := mtTestDirectorySvr.Flags() - cliflagcfg.IntFlag(f, &testDirectorySvrContext.port, cliflags.TestDirectoryListenPort) - cliflagcfg.StringFlag(f, &testDirectorySvrContext.certsDir, cliflags.TestDirectoryTenantCertsDir) - cliflagcfg.StringFlag(f, &testDirectorySvrContext.tenantBaseDir, cliflags.TestDirectoryTenantBaseDir) - cliflagcfg.StringFlag(f, &testDirectorySvrContext.kvAddrs, cliflags.KVAddrs) - } - // userfile upload command. { cliflagcfg.BoolFlag(userFileUploadCmd.Flags(), &userfileCtx.recursive, cliflags.Recursive) @@ -1201,3 +1174,9 @@ func mtStartSQLFlagsInit(cmd *cobra.Command) error { } return nil } + +// RegisterFlags exists so that other packages can register flags using the +// RegisterFlagDepth functions and end up in a call frame in the cli +// package rather than the cliccl package to defeat the duplicate envvar +// registration logic. +func RegisterFlags(f func()) { f() } diff --git a/pkg/cli/mt.go b/pkg/cli/mt.go index 5bc4273a9fe5..0fb7d7c650c4 100644 --- a/pkg/cli/mt.go +++ b/pkg/cli/mt.go @@ -10,13 +10,16 @@ package cli -import "github.com/spf13/cobra" +import ( + "context" + + "github.com/cockroachdb/cockroach/pkg/util/stop" + "github.com/spf13/cobra" +) func init() { - cockroachCmd.AddCommand(mtCmd) - mtCmd.AddCommand(mtStartSQLCmd) - mtCmd.AddCommand(mtStartSQLProxyCmd) - mtCmd.AddCommand(mtTestDirectorySvr) + cockroachCmd.AddCommand(MTCmd) + MTCmd.AddCommand(mtStartSQLCmd) mtCertsCmd.AddCommand( mtCreateTenantCACertCmd, @@ -24,11 +27,11 @@ func init() { mtCreateTenantSigningCertCmd, ) - mtCmd.AddCommand(mtCertsCmd) + MTCmd.AddCommand(mtCertsCmd) } -// mtCmd is the base command for functionality related to multi-tenancy. -var mtCmd = &cobra.Command{ +// MTCmd is the base command for functionality related to multi-tenancy. +var MTCmd = &cobra.Command{ Use: "mt [command]", Short: "commands related to multi-tenancy", Long: ` @@ -53,3 +56,18 @@ This functionality is **experimental** and for internal use only. `, RunE: UsageAndErr, } + +// ClearStoresAndSetupLoggingForMTCommands will clear the cluster name, the +// store specs, and then sets up default logging. +func ClearStoresAndSetupLoggingForMTCommands( + cmd *cobra.Command, ctx context.Context, +) (*stop.Stopper, error) { + serverCfg.ClusterName = "" + serverCfg.Stores.Specs = nil + + stopper, err := setupAndInitializeLoggingAndProfiling(ctx, cmd, false /* isServerCmd */) + if err != nil { + return nil, err + } + return stopper, nil +} diff --git a/pkg/cli/start.go b/pkg/cli/start.go index 203e2484168c..653578126b0c 100644 --- a/pkg/cli/start.go +++ b/pkg/cli/start.go @@ -134,9 +134,15 @@ var serverCmds = append(StartCmds, mtStartSQLCmd) // customLoggingSetupCmds lists the commands that call setupLogging() // after other types of configuration. var customLoggingSetupCmds = append( - serverCmds, debugCheckLogConfigCmd, demoCmd, mtStartSQLProxyCmd, mtTestDirectorySvr, statementBundleRecreateCmd, + serverCmds, debugCheckLogConfigCmd, demoCmd, statementBundleRecreateCmd, ) +// RegisterCommandWithCustomLogging is used by cliccl to note commands which +// want to suppress default logging setup. +func RegisterCommandWithCustomLogging(cmd *cobra.Command) { + customLoggingSetupCmds = append(customLoggingSetupCmds, cmd) +} + func initBlockProfile() { // Enable the block profile for a sample of mutex and channel operations. // Smaller values provide more accurate profiles but are more @@ -442,7 +448,7 @@ func runStartInternal( // the buffers in the signal handler below. If we started capturing // signals later, some startup logging might be lost. signalCh := make(chan os.Signal, 1) - signal.Notify(signalCh, drainSignals...) + signal.Notify(signalCh, DrainSignals...) // Check for stores with full disks and exit with an informative exit // code. This needs to happen early during start, before we perform any @@ -1269,8 +1275,9 @@ disk space exhaustion may result in node loss.`, ballastPathsStr) // setupAndInitializeLoggingAndProfiling does what it says on the label. // Prior to this however it determines suitable defaults for the // logging output directory and the verbosity level of stderr logging. -// We only do this for the "start" and "start-sql" commands which is why this work -// occurs here and not in an OnInitialize function. +// We only do this for special commands which do not use default logging like +// "start" and "start-sql" commands which is why this work occurs here and not +// in an OnInitialize function. func setupAndInitializeLoggingAndProfiling( ctx context.Context, cmd *cobra.Command, isServerCmd bool, ) (stopper *stop.Stopper, err error) { diff --git a/pkg/cli/start_unix.go b/pkg/cli/start_unix.go index 45addbf7c1d4..4c067bf8e16e 100644 --- a/pkg/cli/start_unix.go +++ b/pkg/cli/start_unix.go @@ -28,7 +28,7 @@ import ( "golang.org/x/sys/unix" ) -// drainSignals is the list of signals that trigger the start of a shutdown +// DrainSignals is the list of signals that trigger the start of a shutdown // sequence ("server drain"). // // The first time they're received, both signals initiate a drain just the same. @@ -36,7 +36,7 @@ import ( // more generally, after the drain had started): // - a second SIGTERM is ignored. // - a second SIGINT terminates the process abruptly. -var drainSignals = []os.Signal{unix.SIGINT, unix.SIGTERM} +var DrainSignals = []os.Signal{unix.SIGINT, unix.SIGTERM} // termSignal is the signal that causes an idempotent graceful // shutdown (i.e. second occurrence does not incur hard shutdown). diff --git a/pkg/cli/start_windows.go b/pkg/cli/start_windows.go index ae7de42570bb..7e57e973ecfd 100644 --- a/pkg/cli/start_windows.go +++ b/pkg/cli/start_windows.go @@ -16,8 +16,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/cli/exit" ) -// drainSignals are the signals that will cause the server to drain and exit. -var drainSignals = []os.Signal{os.Interrupt} +// DrainSignals are the signals that will cause the server to drain and exit. +var DrainSignals = []os.Signal{os.Interrupt} // termSignal is the signal that causes an idempotent graceful // shutdown (i.e. second occurrence does not incur hard shutdown).