Skip to content

Commit

Permalink
roachprod: library-ifying roachprod (first pass)
Browse files Browse the repository at this point in the history
In cockroachdb#71660, roachprod library was created under pkg/roachprod
by moving the logic under pkg/cmd/roachprod to pkg/roachprod and
pointing the binary subcommands to the library.

This patch updates the logic to make it more suitable for a library
than a binary and integrates those changes into related tools such
as pkg/cmd/roachprod and pkg/cmd/roachtest.

Release note: None
  • Loading branch information
Ahmad Abedalqader committed Nov 25, 2021
1 parent 8fa3a38 commit ad3bd13
Show file tree
Hide file tree
Showing 22 changed files with 875 additions and 1,822 deletions.
2 changes: 1 addition & 1 deletion build/teamcity-roachtest-invoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bin/roachtest run \
--teamcity \
--roachprod="${PWD}/bin/roachprod" \
--workload="${PWD}/bin/workload" \
--create-args=--os-volume-size=32 \
--os-volume-size=32 \
"$@"
code=$?
set -e
Expand Down
2 changes: 1 addition & 1 deletion build/teamcity-roachtest-stress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ build/teamcity-roachtest-invoke.sh \
--cpu-quota="${CPUQUOTA-1024}" \
--cluster-id="${TC_BUILD_ID}" \
--build-tag="${BUILD_TAG}" \
--create-args="--lifetime=36h" \
--lifetime="36h" \
--cockroach="${PWD}/cockroach-linux-2.6.32-gnu-amd64" \
--artifacts="${PWD}/artifacts" \
--disable-issue \
Expand Down
1 change: 0 additions & 1 deletion pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ ALL_TESTS = [
"//pkg/cmd/publish-artifacts:publish-artifacts_test",
"//pkg/cmd/publish-provisional-artifacts:publish-provisional-artifacts_test",
"//pkg/cmd/roachtest/prometheus:prometheus_test",
"//pkg/cmd/roachtest/spec:spec_test",
"//pkg/cmd/roachtest/tests:tests_test",
"//pkg/cmd/roachtest:roachtest_test",
"//pkg/cmd/teamcity-trigger:teamcity-trigger_test",
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmd/roachprod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ go_library(
"//pkg/roachprod/ssh",
"//pkg/roachprod/ui",
"//pkg/roachprod/vm",
"//pkg/roachprod/vm/aws",
"//pkg/roachprod/vm/azure",
"//pkg/roachprod/vm/gce",
"//pkg/roachprod/vm/local",
"//pkg/util/flagutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_spf13_cobra//:cobra",
"@org_golang_x_term//:term",
],
)

Expand Down
24 changes: 11 additions & 13 deletions pkg/cmd/roachprod/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"os"
"time"

"github.com/cockroachdb/cockroach/pkg/roachprod"
"github.com/cockroachdb/cockroach/pkg/roachprod/config"
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
"github.com/cockroachdb/cockroach/pkg/roachprod/ssh"
Expand All @@ -25,6 +26,7 @@ import (
)

var (
pprofOpts roachprod.PprofOpts
numNodes int
numRacks int
username string
Expand All @@ -50,7 +52,6 @@ var (
adminurlPath = ""
adminurlIPs = false
useTreeDist = true
quiet = false
sig = 9
waitFlag = false
createVMOpts = vm.DefaultCreateOpts()
Expand All @@ -68,17 +69,14 @@ var (
logsFrom time.Time
logsTo time.Time
logsInterval time.Duration
maxConcurrency int

monitorIgnoreEmptyNodes bool
monitorOneShot bool

monitorOpts install.MonitorOpts
cachedHostsCluster string
)

func initFlags() {
rootCmd.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "disable fancy progress output")
rootCmd.PersistentFlags().IntVarP(&maxConcurrency, "max-concurrency", "", 32,
rootCmd.PersistentFlags().BoolVarP(&config.Quiet, "quiet", "q", false, "disable fancy progress output")
rootCmd.PersistentFlags().IntVarP(&config.MaxConcurrency, "max-concurrency", "", 32,
"maximum number of operations to execute on nodes concurrently, set to zero for infinite",
)

Expand Down Expand Up @@ -155,13 +153,13 @@ func initFlags() {
pgurlCmd.Flags().StringVar(&pgurlCertsDir,
"certs-dir", "./certs", "cert dir to use for secure connections")

pprofCmd.Flags().DurationVar(&pprofOptions.duration,
pprofCmd.Flags().DurationVar(&pprofOpts.Duration,
"duration", 30*time.Second, "Duration of profile to capture")
pprofCmd.Flags().BoolVar(&pprofOptions.heap,
pprofCmd.Flags().BoolVar(&pprofOpts.Heap,
"heap", false, "Capture a heap profile instead of a CPU profile")
pprofCmd.Flags().BoolVar(&pprofOptions.open,
pprofCmd.Flags().BoolVar(&pprofOpts.Open,
"open", false, "Open the profile using `go tool pprof -http`")
pprofCmd.Flags().IntVar(&pprofOptions.startingPort,
pprofCmd.Flags().IntVar(&pprofOpts.StartingPort,
"starting-port", 9000, "Initial port to use when opening pprof's HTTP interface")

ipCmd.Flags().BoolVar(&external,
Expand Down Expand Up @@ -210,12 +208,12 @@ func initFlags() {
logsCmd.Flags().StringVar(&logsProgramFilter,
"logs-program", "^cockroach$", "regular expression of the name of program in log files to search")

monitorCmd.Flags().BoolVar(&monitorIgnoreEmptyNodes,
monitorCmd.Flags().BoolVar(&monitorOpts.IgnoreEmptyNodes,
"ignore-empty-nodes", false,
"Automatically detect the (subset of the given) nodes which to monitor "+
"based on the presence of a nontrivial data directory.")

monitorCmd.Flags().BoolVar(&monitorOneShot,
monitorCmd.Flags().BoolVar(&monitorOpts.OneShot,
"oneshot", false,
"Report the status of all targeted nodes once, then exit. The exit "+
"status is nonzero if (and only if) any node was found not running.")
Expand Down
Loading

0 comments on commit ad3bd13

Please sign in to comment.