Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: circular dependencies are not obvious #74858

Open
irfansharif opened this issue Jan 14, 2022 · 2 comments
Open

bazel: circular dependencies are not obvious #74858

irfansharif opened this issue Jan 14, 2022 · 2 comments
Labels
A-build-system C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-dev-inf

Comments

@irfansharif
Copy link
Contributor

irfansharif commented Jan 14, 2022

Describe the problem

Circular dependency errors don't show up prominently with bazel/dev, making it non-obvious to diagnose. Probably we're eating up a helpful error message somewhere.

To Reproduce

Try this diff + dev gen bazel.

diff --git a/pkg/testutils/localtestcluster/BUILD.bazel b/pkg/testutils/localtestcluster/BUILD.bazel
index b13280b529..3e42b060b2 100644
--- a/pkg/testutils/localtestcluster/BUILD.bazel
+++ b/pkg/testutils/localtestcluster/BUILD.bazel
@@ -19,6 +19,7 @@ go_library(
         "//pkg/roachpb:with-mocks",
         "//pkg/rpc",
         "//pkg/settings/cluster",
+        "//pkg/spanconfig/spanconfigkvsubscriber",
         "//pkg/sql/catalog/bootstrap",
         "//pkg/storage",
         "//pkg/util",
diff --git a/pkg/testutils/localtestcluster/local_test_cluster.go b/pkg/testutils/localtestcluster/local_test_cluster.go
index 42eeee4305..a4f10a83c1 100644
--- a/pkg/testutils/localtestcluster/local_test_cluster.go
+++ b/pkg/testutils/localtestcluster/local_test_cluster.go
@@ -29,6 +29,7 @@ import (
 	"github.com/cockroachdb/cockroach/pkg/roachpb"
 	"github.com/cockroachdb/cockroach/pkg/rpc"
 	"github.com/cockroachdb/cockroach/pkg/settings/cluster"
+	"github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigkvsubscriber"
 	"github.com/cockroachdb/cockroach/pkg/sql/catalog/bootstrap"
 	"github.com/cockroachdb/cockroach/pkg/storage"
 	"github.com/cockroachdb/cockroach/pkg/util"
@@ -39,6 +40,8 @@ import (
 	"github.com/cockroachdb/cockroach/pkg/util/tracing"
 )
 
+var _ = spanconfigkvsubscriber.KVSubscriber{}
+
 // A LocalTestCluster encapsulates an in-memory instantiation of a
 // cockroach node with a single store using a local sender. Example
 // usage of a LocalTestCluster follows:
$ dev test pkg/kv/kvclient/kvcoord -f=TestRangeSplitsWithWritePressure -v
[...]
ERROR: /Users/irfansharif/Software/src/github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord/BUILD.bazel:109:8: GoCompilePkg pkg/kv/kvclient/kvcoord/kvcoord_test.internal.recompileinternal.a failed: (Exit 1): builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_amd64 -tags bazel,gss,bazel,gss -src pkg/kv/kvclient/kvcoord/batch.go -src ... (remaining 267 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
compilepkg: missing strict dependencies:
        /private/var/tmp/_bazel_irfansharif/99e666e4e674209ecdb66b46371278df/sandbox/darwin-sandbox/1555/execroot/cockroach/pkg/kv/kvclient/kvcoord/split_test.go: import of "github.com/cockroachdb/cockroach/pkg/testutils/localtestcluster"
        /private/var/tmp/_bazel_irfansharif/99e666e4e674209ecdb66b46371278df/sandbox/darwin-sandbox/1555/execroot/cockroach/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go: import of "github.com/cockroachdb/cockroach/pkg/testutils/localtestcluster"
        /private/var/tmp/_bazel_irfansharif/99e666e4e674209ecdb66b46371278df/sandbox/darwin-sandbox/1555/execroot/cockroach/pkg/kv/kvclient/kvcoord/txn_correctness_test.go: import of "github.com/cockroachdb/cockroach/pkg/testutils/localtestcluster"
        /private/var/tmp/_bazel_irfansharif/99e666e4e674209ecdb66b46371278df/sandbox/darwin-sandbox/1555/execroot/cockroach/pkg/kv/kvclient/kvcoord/txn_test.go: import of "github.com/cockroachdb/cockroach/pkg/testutils/localtestcluster"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
[...]
FAILED: Build did NOT complete successfully
//pkg/kv/kvclient/kvcoord:kvcoord_test                          FAILED TO BUILD

Expected behavior

The make output is much more helpful:

$ make test PKG=./pkg/kv/kvclient/kvcoord TESTS=TestRangeSplitsWithWritePressure
[...]
# github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord
package github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord
        imports github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed
        imports github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigkvsubscriber
        imports github.com/cockroachdb/cockroach/pkg/testutils/localtestcluster: import cycle not allowed in test
FAIL    github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord [setup failed]
FAIL
make: *** [test] Error 1

Epic CRDB-17171
Jira issue: CRDB-12297

@irfansharif irfansharif added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-build-system labels Jan 14, 2022
@irfansharif
Copy link
Contributor Author

Upstream: bazelbuild/rules_go#2583.

@andreimatei
Copy link
Contributor

The upstream issue was fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-system C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-dev-inf
Projects
None yet
Development

No branches or pull requests

3 participants