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

unable to build kubernetes/client-go #1356

Closed
jmhodges opened this issue Feb 27, 2018 · 6 comments
Closed

unable to build kubernetes/client-go #1356

jmhodges opened this issue Feb 27, 2018 · 6 comments

Comments

@jmhodges
Copy link
Contributor

With

go_repository(
    name = "io_k8s_api",
    importpath = "k8s.io/api",
    tag = "kubernetes-1.9.3",
)

go_repository(
    name = "io_k8s_apimachinery",
    tag = "kubernetes-1.9.3",
    importpath = "k8s.io/apimachinery",
)

go_repository(
    name = "io_k8s_client_go",
    tag = "v6.0.0",
    importpath = "k8s.io/client-go",
)

and then depending on "@io_k8s_client_go//kubernetes/typed/core/v1:go_default_library" in a target, you'll get an error like:

$  bazel test //path/to/whatever:go_default_test 
ERROR: /private/var/tmp/_bazel_jmhodges/ee957dabdee1b1a9e1f2fe90369cf80f/external/io_k8s_api/core/v1/BUILD:80:1: no such package '@io_k8s_api//k8s.io/apimachinery/pkg/runtime/schema': BUILD file not found on package path and referenced by '@io_k8s_api//core/v1:v1_go_proto'
ERROR: Analysis of target '//path/to/whatever:go_default_test' failed; build aborted: no such package '@io_k8s_api//k8s.io/apimachinery/pkg/runtime/schema': BUILD file not found on package path
INFO: Elapsed time: 112.948s
FAILED: Build did NOT complete successfully (111 packages loaded)
    currently loading: @io_k8s_apimachinery//pkg/runtime/serializer/versioning ... (7 packages)
ERROR: Couldn't start the build. Unable to run tests
@jmhodges
Copy link
Contributor Author

I took a whack at this with the build_file_name = "BUILD.bazel"addition to apimachinery mentioned in #865, thinking maybe it was related, and that didn't work.

I'm not sure how to solve this problem and I'm pretty frustrated.

@jayconrod
Copy link
Contributor

I looked into this a bit. I saw similar but different errors in io_k8s_apimachinery. I think io_k8s_api has the same issue.

As I understand, k8s.io/apimachinery is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery. BUILD files are generated in kubernetes, committed into in kubernetes, then synced along with everything else. These BUILD files are broken during sync, since they contain repository-absolute paths that don't make sense anymore. I think the BUILD files should be either fixed on sync or deleted.

I have a call scheduled with @ixdy later today. Hope to learn more then.

@jayconrod
Copy link
Contributor

I've filed kubernetes/publishing-bot#49 to look into this. I'll close the issue here, since I don't think there's anything to be done in rules_go.

Since these repositories already has build files, it's probably better to use git_repository instead of go_repository. Or go_repository with build_file_generation = "off", which will give you the Go import path redirection. The build files are still broken though. :(

@jmhodges
Copy link
Contributor Author

jmhodges commented Feb 28, 2018

Cool. I didn't realize there were still BUILD files in there because I went and looked for WORKSPACE files and didn't see them.

A simple fix to get me by til kubernetes/publishing-bot#49 is fixed will be to fork them and delete the files myself. It's late in the day, so I think I'll have to do that to get unblocked.

@base698
Copy link

base698 commented Jan 16, 2021

Any work arounds?

@sabeer6870
Copy link

I used sum explicitly and it worked for me:

go_repository(
    name = "io_k8s_apimachinery",
    build_file_proto_mode = "disable",
    importpath = "k8s.io/apimachinery",
    sum = "h1:DTARnyzmdHMz7bFWFDDm22AM4pLWTQECMpRTFu2d2OM=",
    version = "v0.22.1",
)

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