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

Gazelle: no such package '@com_github_cncf_xds_go//udpa/annotations': BUILD file not found in directory 'udpa/annotations' #104

Open
sfc-gh-ptabor opened this issue Oct 1, 2024 · 7 comments

Comments

@sfc-gh-ptabor
Copy link

We are using gazelle to generate bazel bindings to the golang code. The version v0.0.0-20240905190251-b4127c9b8d78 fails with:

bazel run //:{redacted}
INFO: Repository org_golang_google_protobuf instantiated at:
...
INFO: repository @org_golang_google_protobuf' used the following cache hits instead of downloading the corresponding file.
 * Hash '39a8bbfadaa3e71f9d7741d67ee60d69db40422dc531708a777259e594d923e3' for https://mirror.bazel.build/github.com/protocolbuffers/protobuf-go/archive/refs/tags/v1.33.0.zip
If the definition of 'repository @org_golang_google_protobuf' was updated, verify that the hashes were also updated.
ERROR: /{redacted}/external/com_github_envoyproxy_go_control_plane/envoy/service/auth/v3/BUILD.bazel:3:11: no such package '@com_github_cncf_xds_go//udpa/annotations': BUILD file not found in directory 'udpa/annotations' of external repository @com_github_cncf_xds_go. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_envoyproxy_go_control_plane//envoy/service/auth/v3:auth'
ERROR: Analysis of target '//:{redacted}' failed; build aborted:
INFO: Elapsed time: 2.685s
INFO: 0 processes.
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully (87 packages loaded, 4389 targets configured)

The version github.com/cncf/xds/[email protected] works ok. It's regression in the newer versions.

My hypothesis about the root reason: @keith added in #96 a /go/BUILD file.
The file makes gazelle consider this whole subtree as a proper BAZEL project... so suspends gazelle for generating the proper BUILD files in the sub tree... But they are missing there... i.e. there are no proper BUILD files, e.g. in: https://github.com/cncf/xds/tree/main/go/udpa/annotations.

Can we make it either proper bazel project with gazelle generated BUILD targets...
or rollback the BUILD file in the subtree at all ?

@EdSchouten
Copy link

You can currently work around this issue by adding this to your MODULE.bazel:

go_deps.gazelle_override(
    build_file_generation = "on",
    path = "github.com/cncf/xds/go",
)

But I agree: removing go/BUILD would be preferable, because that would make it work out of the box.

@adisuissa
Copy link

cc @keith @mmorel-35 - should #96 be reverted, or should the /go/BUILD file be removed or fixed?

@EdSchouten
Copy link

I’d say, don’t revert it. Just remove go/BUILD.

@EdSchouten
Copy link

Oh wait. That does require us to change some of the //go:go.* references in MODULE.bazel to //:go/go.*.

msanft added a commit to edgelesssys/constellation that referenced this issue Oct 15, 2024
xDS has an upstream set of build files that makes Gazelle consider their project a whole new Bazel project, which makes Gazelle not generate any build files, even though the upstream ones aren't valid.

See cncf/xds#104.
msanft added a commit to edgelesssys/constellation that referenced this issue Oct 16, 2024
* deps: update Go dependencies

* bazel: force Gazelle generation for xDS

xDS has an upstream set of build files that makes Gazelle consider their project a whole new Bazel project, which makes Gazelle not generate any build files, even though the upstream ones aren't valid.

See cncf/xds#104.

* go: update cel.dev/expr for Bazel fixes

cel.dev/expr had some upstream Bazel fixes in v0.16.2 without which Gazelle doesn't work.

* chore: generate

* e2e: remove references to kubeProxyVersion

kubeProxyVersion is deprecated as of KEP-4004. It was never being set to an accurate value before, and we only used it in the e2e test, so removing the additional check should not hurt here.

See https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/4004-deprecate-kube-proxy-version

* constellation-node-operator: use typed rate-limiter

The untyped rate-limiter was deprecated in favor of a generic one that can just be instantiated to `any` to achieve the previous behaviour.

* Advertise ALPN settings in NextProtos required by gRPC

Signed-off-by: Daniel Weiße <[email protected]>

* atls: add nextProtos

nextProtos (for ALPN) is now required by gRPC, so add it.

* go: add cri-client replace

* deps: tidy all modules

---------

Signed-off-by: Daniel Weiße <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Moritz Sanft <[email protected]>
Co-authored-by: Daniel Weiße <[email protected]>
Co-authored-by: edgelessci <[email protected]>
@brycefisher
Copy link

@EdSchouten I'd like to apply your workaround, but I'm using WORKSPACE instead of Bzlmod. Is there an equivalent way to alter a dep?

@EdSchouten
Copy link

EdSchouten commented Nov 28, 2024

@EdSchouten I'd like to apply your workaround, but I'm using WORKSPACE instead of Bzlmod. Is there an equivalent way to alter a dep?

Search for the go_repository(name = "com_github_cncf_xds_go") and add build_file_generation = "on" to that...?

@brycefisher
Copy link

Ah, thank you!! That totally works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants