Skip to content

Commit 323f5af

Browse files
craig[bot]shailendra-patel
andcommitted
Merge #159492
159492: roachprod/cli: honor COCKROACH_ROACHPROD_INSECURE for ephemeral clusters r=shailendra-patel a=shailendra-patel Previously, clusters in `cockroach-ephemeral` always defaulted to insecure mode, ignoring the `COCKROACH_ROACHPROD_INSECURE` env var. The only way to force secure mode was passing `--secure` explicitly. Now, if `COCKROACH_ROACHPROD_INSECURE` is explicitly set, it takes precedence over the ephemeral project default. Setting it to `false` forces secure mode, `true` forces insecure. CLI flags still have highest precedence. Release note: None Epic: None Co-authored-by: Shailendra Patel <[email protected]>
2 parents 95e070e + 651cba5 commit 323f5af

File tree

3 files changed

+83
-62
lines changed

3 files changed

+83
-62
lines changed

pkg/cmd/drtprod/configs/drt_pua_mr.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ environment:
1717
# variables used by tpcc_run_multiregion.sh
1818
NUM_REGIONS: 3
1919
NODES_PER_REGION: 5
20-
REGIONS: us-central1,us-east5,us-east1
20+
REGIONS: us-central1,us-east4,us-east1
2121
TPCC_WAREHOUSES: 10000
2222
TPCC_ACTIVE_WAREHOUSES: 7000
2323
DB_NAME: cct_tpcc
@@ -55,7 +55,7 @@ targets:
5555
clouds: gce
5656
gce-managed: true
5757
gce-enable-multiple-stores: true
58-
gce-zones: "us-central1-a:2,us-central1-b:2,us-central1-c:1,us-east5-a:2,us-east5-b:2,us-east5-c:1,us-east1-b:2,us-east1-c:2,us-east1-d:1"
58+
gce-zones: "us-central1-a:2,us-central1-b:2,us-central1-c:1,us-east4-a:2,us-east4-b:2,us-east4-c:1,us-east1-b:2,us-east1-c:2,us-east1-d:1"
5959
nodes: $CLUSTER_NODES
6060
gce-machine-type: n2-standard-16
6161
local-ssd: true
@@ -147,7 +147,7 @@ targets:
147147
- $WORKLOAD_CLUSTER
148148
flags:
149149
clouds: gce
150-
gce-zones: "us-central1-a,us-east5-a,us-east1-b"
150+
gce-zones: "us-central1-a,us-east4-a,us-east1-b"
151151
nodes: $NUM_REGIONS
152152
gce-machine-type: n2d-standard-4
153153
os-volume-size: 100
@@ -261,7 +261,7 @@ targets:
261261
- -e
262262
- |
263263
BACKUP INTO ('gs://$BUCKET_US_CENTRAL1/$CLUSTER?AUTH=implicit&COCKROACH_LOCALITY=default',
264-
'gs://$BUCKET_US_EAST_5/$CLUSTER?AUTH=implicit&COCKROACH_LOCALITY=region%3Dus-east5',
264+
'gs://$BUCKET_US_EAST_5/$CLUSTER?AUTH=implicit&COCKROACH_LOCALITY=region%3Dus-east4',
265265
'gs://$BUCKET_US_EAST_1/$CLUSTER?AUTH=implicit&COCKROACH_LOCALITY=region%3Dus-east1')
266266
WITH OPTIONS (revision_history = true, detached)
267267
wait_after: 1500

pkg/cmd/roachprod/cli/flags.go

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,62 +28,62 @@ import (
2828

2929
var (
3030
// Do not populate providerOptsContainer here as we need to call InitProivders() first.
31-
providerOptsContainer vm.ProviderOptionsContainer
32-
pprofOpts roachprod.PprofOpts
33-
numNodes int
34-
numRacks int
35-
username string
36-
database string
37-
dryrun bool
38-
destroyAllMine bool
39-
destroyAllLocal bool
40-
extendLifetime time.Duration
41-
wipePreserveCerts bool
42-
grafanaConfig string
43-
grafanaArch string
44-
grafanaDumpDir string
45-
jaegerConfigNodes string
46-
listCost bool
47-
listDetails bool
48-
listJSON bool
49-
listMine bool
50-
listPattern string
51-
isSecure install.ComplexSecureOption // Set based on the values passed to --secure and --insecure
52-
secure = true
53-
insecure = envutil.EnvOrDefaultBool("COCKROACH_ROACHPROD_INSECURE", false)
54-
virtualClusterName string
55-
sqlInstance int
56-
extraSSHOptions = ""
57-
exportSSHConfig string
58-
nodeEnv []string
59-
tag string
60-
external = false
61-
pgurlCertsDir string
62-
authMode string
63-
adminurlPath = ""
64-
adminurlIPs = false
65-
urlOpen = false
66-
useTreeDist = true
67-
sig = 9
68-
waitFlag = false
69-
gracePeriod = 0
70-
deploySig = 15
71-
deployWaitFlag = true
72-
deployGracePeriod = 300
73-
pause = time.Duration(0)
74-
createVMOpts = vm.DefaultCreateOpts()
75-
startOpts = roachprod.DefaultStartOpts()
76-
stageOS string
77-
stageArch string
78-
stageDir string
79-
logsDir string
80-
logsFilter string
81-
logsProgramFilter string
82-
logsFrom time.Time
83-
logsTo time.Time
84-
logsInterval time.Duration
85-
volumeCreateOpts vm.VolumeCreateOpts
86-
listOpts vm.ListOptions
31+
providerOptsContainer vm.ProviderOptionsContainer
32+
pprofOpts roachprod.PprofOpts
33+
numNodes int
34+
numRacks int
35+
username string
36+
database string
37+
dryrun bool
38+
destroyAllMine bool
39+
destroyAllLocal bool
40+
extendLifetime time.Duration
41+
wipePreserveCerts bool
42+
grafanaConfig string
43+
grafanaArch string
44+
grafanaDumpDir string
45+
jaegerConfigNodes string
46+
listCost bool
47+
listDetails bool
48+
listJSON bool
49+
listMine bool
50+
listPattern string
51+
isSecure install.ComplexSecureOption // Set based on the values passed to --secure and --insecure
52+
secure = true
53+
insecure, insecureEnvSet = getInsecureEnvVar() // Get both value and whether it was explicitly set
54+
virtualClusterName string
55+
sqlInstance int
56+
extraSSHOptions = ""
57+
exportSSHConfig string
58+
nodeEnv []string
59+
tag string
60+
external = false
61+
pgurlCertsDir string
62+
authMode string
63+
adminurlPath = ""
64+
adminurlIPs = false
65+
urlOpen = false
66+
useTreeDist = true
67+
sig = 9
68+
waitFlag = false
69+
gracePeriod = 0
70+
deploySig = 15
71+
deployWaitFlag = true
72+
deployGracePeriod = 300
73+
pause = time.Duration(0)
74+
createVMOpts = vm.DefaultCreateOpts()
75+
startOpts = roachprod.DefaultStartOpts()
76+
stageOS string
77+
stageArch string
78+
stageDir string
79+
logsDir string
80+
logsFilter string
81+
logsProgramFilter string
82+
logsFrom time.Time
83+
logsTo time.Time
84+
logsInterval time.Duration
85+
volumeCreateOpts vm.VolumeCreateOpts
86+
listOpts vm.ListOptions
8787

8888
monitorOpts install.MonitorOpts
8989
cachedHostsCluster string
@@ -109,11 +109,24 @@ var (
109109
fetchLogsTimeout time.Duration
110110
)
111111

112+
// getInsecureEnvVar returns the value of COCKROACH_ROACHPROD_INSECURE and
113+
// whether it was explicitly set.
114+
func getInsecureEnvVar() (bool, bool) {
115+
val, ok := envutil.EnvString("COCKROACH_ROACHPROD_INSECURE", 1)
116+
if !ok {
117+
return false, false
118+
}
119+
return val == "true" || val == "1", true
120+
}
121+
112122
// Intended to be called once from drtprod main package to update defaults which differ from roachprod.
113123
func UpdateFlagDefaults() {
114-
// N.B. unlike roachprod, which defaults to "insecure mode", drtprod defaults to "secure mode".
124+
// N.B. Both roachprod and drtprod default to secure mode via the flag defaults.
125+
// However, roachprod has runtime logic in overrideBasedOnClusterSettings() that
126+
// forces insecure mode for clusters in the cockroach-ephemeral GCP project.
127+
// drtprod explicitly sets secure=true here to ensure secure mode is used.
115128
secure = true
116-
insecure = envutil.EnvOrDefaultBool("COCKROACH_ROACHPROD_INSECURE", false)
129+
// insecure and insecureEnvSet are already initialized via getInsecureEnvVar()
117130
}
118131

119132
func initRootCmdFlags(rootCmd *cobra.Command) {

pkg/cmd/roachprod/cli/util.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ func isSecureCluster(cmd *cobra.Command) (install.ComplexSecureOption, error) {
143143
case hasInsecureFlag:
144144
return install.ComplexSecureOption{ForcedInsecure: true}, nil
145145

146+
case insecureEnvSet:
147+
// If COCKROACH_ROACHPROD_INSECURE env var was explicitly set, treat it
148+
// as a forced setting that takes precedence over ephemeral project defaults.
149+
if insecure {
150+
return install.ComplexSecureOption{ForcedInsecure: true}, nil
151+
}
152+
return install.ComplexSecureOption{ForcedSecure: true}, nil
153+
146154
default:
147155
return install.ComplexSecureOption{DefaultSecure: !insecure}, nil
148156
}

0 commit comments

Comments
 (0)