Skip to content

Commit

Permalink
roachprod: making roachprod subcommands point to a new library
Browse files Browse the repository at this point in the history
Previously, roachprod binary interfaced directly with roachorod's functionality
and there was no way for another tool to make use of that functionality.

This needed to change to create a library that can be used by roachprod binary
and also other tools.

This patch migrates the subcommands functionality to a new library and makes
the binary point to the new library.

Release note: None
  • Loading branch information
Ahmad Abedalqader committed Oct 31, 2021
1 parent db229ca commit ed5ed54
Show file tree
Hide file tree
Showing 78 changed files with 1,856 additions and 1,325 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
/pkg/roachpb/string_test.go @cockroachdb/kv-prs
/pkg/roachpb/tenant* @cockroachdb/kv-prs
/pkg/roachpb/version* @cockroachdb/server
/pkg/roachprod/ @cockroachdb/dev-inf
/pkg/rpc/ @cockroachdb/server-prs
/pkg/scheduledjobs/ @cockroachdb/bulk-prs
/pkg/security/ @cockroachdb/server-prs @cockroachdb/prodsec
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ optgen-package = ./pkg/sql/opt/optgen/cmd/optgen
logictest-package = ./pkg/sql/logictest
logictestccl-package = ./pkg/ccl/logictestccl
logictestopt-package = ./pkg/sql/opt/exec/execbuilder
terraformgen-package = ./pkg/cmd/roachprod/vm/aws/terraformgen
terraformgen-package = ./pkg/roachprod/vm/aws/terraformgen
logictest-bins := bin/logictest bin/logictestopt bin/logictestccl

# Additional dependencies for binaries that depend on generated code.
Expand Down
10 changes: 5 additions & 5 deletions build/bazelutil/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
set -euo pipefail

EXISTING_GO_GENERATE_COMMENTS="
pkg/cmd/roachprod/vm/aws/config.go://go:generate go-bindata -mode 0600 -modtime 1400000000 -pkg aws -o embedded.go config.json old.json
pkg/cmd/roachprod/vm/aws/config.go://go:generate gofmt -s -w embedded.go
pkg/cmd/roachprod/vm/aws/config.go://go:generate goimports -w embedded.go
pkg/cmd/roachprod/vm/aws/config.go://go:generate terraformgen -o terraform/main.tf
pkg/roachprod/vm/aws/config.go://go:generate go-bindata -mode 0600 -modtime 1400000000 -pkg aws -o embedded.go config.json old.json
pkg/roachprod/vm/aws/config.go://go:generate gofmt -s -w embedded.go
pkg/roachprod/vm/aws/config.go://go:generate goimports -w embedded.go
pkg/roachprod/vm/aws/config.go://go:generate terraformgen -o terraform/main.tf
pkg/cmd/roachtest/prometheus/prometheus.go://go:generate mockgen -package=prometheus -destination=mock_generated.go -source=prometheus.go . Cluster
pkg/cmd/roachtest/tests/drt.go://go:generate mockgen -source drt.go -package tests -destination drt_generated.go
pkg/kv/kvclient/kvcoord/transport.go://go:generate mockgen -package=kvcoord -destination=mocks_generated.go . Transport
Expand Down Expand Up @@ -84,4 +84,4 @@ git grep 'broken_in_bazel' pkg | grep BUILD.bazel: | grep -v pkg/BUILD.bazel | g
echo "A new broken test in Bazel was added in $LINE"
echo 'Ensure the test runs with Bazel, then remove the broken_in_bazel tag.'
exit 1
done
done
8 changes: 4 additions & 4 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ ALL_TESTS = [
"//pkg/cmd/prereqs:prereqs_test",
"//pkg/cmd/publish-artifacts:publish-artifacts_test",
"//pkg/cmd/publish-provisional-artifacts:publish-provisional-artifacts_test",
"//pkg/cmd/roachprod/cloud:cloud_test",
"//pkg/cmd/roachprod/install:install_test",
"//pkg/cmd/roachprod/ssh:ssh_test",
"//pkg/cmd/roachprod/vm:vm_test",
"//pkg/cmd/roachtest/prometheus:prometheus_test",
"//pkg/cmd/roachtest/spec:spec_test",
"//pkg/cmd/roachtest/tests:tests_test",
Expand Down Expand Up @@ -161,6 +157,10 @@ ALL_TESTS = [
"//pkg/migration/migrations:migrations_test",
"//pkg/roachpb:roachpb_test",
"//pkg/roachpb:string_test",
"//pkg/roachprod/cloud:cloud_test",
"//pkg/roachprod/install:install_test",
"//pkg/roachprod/ssh:ssh_test",
"//pkg/roachprod/vm:vm_test",
"//pkg/rpc/nodedialer:nodedialer_test",
"//pkg/rpc:rpc_test",
"//pkg/security/certmgr:certmgr_test",
Expand Down
34 changes: 12 additions & 22 deletions pkg/cmd/roachprod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "roachprod_lib",
srcs = [
"hosts.go",
"main.go",
],
srcs = ["main.go"],
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/roachprod",
visibility = ["//visibility:private"],
deps = [
"//pkg/build",
"//pkg/cmd/roachprod/cloud",
"//pkg/cmd/roachprod/config",
"//pkg/cmd/roachprod/errors",
"//pkg/cmd/roachprod/install",
"//pkg/cmd/roachprod/ssh",
"//pkg/cmd/roachprod/ui",
"//pkg/cmd/roachprod/vm",
"//pkg/cmd/roachprod/vm/aws",
"//pkg/cmd/roachprod/vm/azure",
"//pkg/cmd/roachprod/vm/gce",
"//pkg/cmd/roachprod/vm/local",
"//pkg/util/ctxgroup",
"//pkg/roachprod",
"//pkg/roachprod/config",
"//pkg/roachprod/errors",
"//pkg/roachprod/install",
"//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",
"//pkg/util/httputil",
"//pkg/util/syncutil",
"//pkg/util/timeutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_errors//oserror",
"@com_github_spf13_cobra//:cobra",
"@org_golang_x_sys//unix",
"@org_golang_x_term//:term",
],
)

Expand Down
Loading

0 comments on commit ed5ed54

Please sign in to comment.