Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Support protocol buffers as a transport medium in the cluster registry #178

Merged
merged 3 commits into from
Jan 26, 2018

Conversation

perotinus
Copy link
Contributor

/sig multicluster

/cc @font @madhusudancs @pmorie

Fixes #106.

@k8s-ci-robot k8s-ci-robot added sig/multicluster Categorizes an issue or PR as relevant to SIG Multicluster. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 17, 2018
@perotinus perotinus force-pushed the protos branch 3 times, most recently from 5072827 to 12826af Compare January 18, 2018 23:16
Copy link
Contributor

@font font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool to see this!

Would you be able to explain the difference between the vendoring changes and the third_party changes? I think the latter is the C++ implementation of protocol buffers (protoc compiler), while the former is the changes to vendor in the protobuf Golang generator protoc-gen-gogo from k8s.io/code-generator and the specific Golang compiler plugin from github.com/gogo/protobuf. Is that right?

//vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo \
//third_party/protobuf:protoc

PATH="$(bazel info bazel-bin)/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo:$(bazel info bazel-bin)/third_party/protobuf:${PATH}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact of how the protocol buffer compiler works: it expects to be able to call plugins from the PATH. A bit of a pain, but able to be worked around like so.

Though, with the latest changes to rules_go, this has gotten a bit more complex.

@font
Copy link
Contributor

font commented Jan 23, 2018

Also looks like this needs a rebase and retesting.

@perotinus
Copy link
Contributor Author

@font Rebased, and I'll fix any additional test failures.

I removed the third_party directory, since I realized that a dependency is already pulling in the protobuf library into the bazel workspace. This might not be a great long-term solution, but at least for now I think we can rely on it, and it makes this PR simpler. The original reason for the third_party directory was that dep was not very good at pulling in the protobuf package, since it didn't all contain Go code. I added protobuf to third_party as a workaround (like k/k does, though they import significantly less of the repo), but changed that when I realized that I could use the version of protobuf from the bazel workspace.

@perotinus
Copy link
Contributor Author

Looks like go-to-protobuf calls goimports and gofmt in an exec.Command, assuming that it is in the path. This will require some extra thinking. I suppose the verify script could go get gofmt and goimports if they are not already in the PATH, but that's a bit of a pain

@perotinus
Copy link
Contributor Author

@font In any case, this should be ready to review; that infrastructure issue will need to be fixed before submission, but it shouldn't be a review blocker.

Copy link
Contributor

@font font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and simpler now without third_party!

Curious, how does the bazel workspace contain a version of protobuf?

For the infrastructure test failure, you should be able to use the same image kubekins-e2e we're using for the pull-cluster-registry-verify-gosrc job, as that one contains the Go toolchain whereas the bazelbuild image used by the pull-cluster-registry-verify-gensrc job does not. It also contains bazel as I understand. So we may want to eventually convert all of the jobs to use kubekins-e2e.

PROTOC_GEN_GOGO_PATH="$(dirname "$(bazel build //vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo:protoc-gen-gogo 2>&1 | grep bazel-bin | xargs)")"
PROTOC_PATH="$(dirname "$(bazel build @com_google_protobuf//:protoc 2>&1 | grep bazel-bin | xargs)")"

PATH="$(bazel info workspace)/${PROTOC_PATH}:$(bazel info workspace)/${PROTOC_GEN_GOGO_PATH}:${PATH}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment explaining that it's for the compiler to find the plugins?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Gopkg.toml Outdated
ignored = ["github.com/kubernetes/repo-infra/kazel"]
ignored = [
"github.com/kubernetes/repo-infra/kazel",
"github.com/google/protobuf/*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a transitive dependency requiring dep to ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I thought I had removed this, but I'll make sure it's actually gone. Perhaps it slipped into another commit as I was rebasing.

@perotinus
Copy link
Contributor Author

/test pull-cluster-registry-verify-gensrc

1 similar comment
@perotinus
Copy link
Contributor Author

/test pull-cluster-registry-verify-gensrc

@perotinus
Copy link
Contributor Author

@font I expect that some other dependency that's in the workspace requires the protobuf library, and so it's pulled in. My guess would be that rules_go depends on the protocol buffers library for the golang protobuf rules.

@perotinus
Copy link
Contributor Author

/test pull-cluster-registry-verify-gensrc

@krzyzacy
Copy link

/retest

1 similar comment
@krzyzacy
Copy link

/retest

@perotinus
Copy link
Contributor Author

@font It looks like the kubekins-e2e image doesn't have goimports either. I suppose we could download it before running the test if it's not in the path.

@perotinus
Copy link
Contributor Author

@font OK, I fixed the issue with goimports by downloading it on each run of hack/verify-all-gensrc if it's not in the PATH. PTAL.

@font
Copy link
Contributor

font commented Jan 26, 2018

@perotinus /lgtm

@perotinus
Copy link
Contributor Author

/meow

@k8s-ci-robot
Copy link
Contributor

@perotinus: cat image

In response to this:

/meow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@font
Copy link
Contributor

font commented Jan 26, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: font, perotinus

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 9430855 into kubernetes-retired:master Jan 26, 2018
@perotinus perotinus deleted the protos branch January 26, 2018 01:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. sig/multicluster Categorizes an issue or PR as relevant to SIG Multicluster. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants