Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Update Kubernetes deps to use release-1.8 branches #47

Merged
merged 6 commits into from
Oct 22, 2017
Merged

Conversation

munnerz
Copy link
Contributor

@munnerz munnerz commented Oct 19, 2017

No description provided.

@munnerz
Copy link
Contributor Author

munnerz commented Oct 19, 2017

Since kubernetes/kubernetes#52186 has merged, we can now really easily build generators and also generate files. We should gradually switch all of our projects over to use these new generate-* scripts.

This PR switches us to use this, fixes us to the release-1.8 branches of the Kubernetes API repositories, and updates the import paths for the newly generated files.

Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Thanks @munnerz

  • I checked out the branch and ran dep ensure -v --dry-run --no-vendor. It reports:

Gopkg.lock was not up to date

  • I ran make all and got the following error:
vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go:57: cannot use info (type *"github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".UnaryServerInfo) as type *"google.golang.org/grpc".UnaryServerInfo in argument to grpc_prometheus.UnaryServerInterceptor
vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go:57: cannot use handler (type "github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".UnaryHandler) as type "google.golang.org/grpc".UnaryHandler in argument to grpc_prometheus.UnaryServerInterceptor
vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go:93: cannot use ss (type "github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".ServerStream) as type "google.golang.org/grpc".ServerStream in argument to grpc_prometheus.StreamServerInterceptor:
	"github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".ServerStream does not implement "google.golang.org/grpc".ServerStream (wrong type for Context method)
		have Context() "github.com/jetstack-experimental/navigator/vendor/golang.org/x/net/context".Context
		want Context() "golang.org/x/net/context".Context
vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go:93: cannot use info (type *"github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".StreamServerInfo) as type *"google.golang.org/grpc".StreamServerInfo in argument to grpc_prometheus.StreamServerInterceptor
vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go:93: cannot use handler (type "github.com/jetstack-experimental/navigator/vendor/google.golang.org/grpc".StreamHandler) as type "google.golang.org/grpc".StreamHandler in argument to grpc_prometheus.StreamServerInterceptor
FAIL	github.com/jetstack-experimental/navigator/pkg/registry/navigator/cassandracluster [build failed]
?   	github.com/jetstack-experimental/navigator/pkg/registry/navigator/escluster	[no test files]
?   	github.com/jetstack-experimental/navigator/pkg/registry/navigator/pilot	[no test files]
?   	github.com/jetstack-experimental/navigator/pkg/test/integration/framework	[no test files]
?   	github.com/jetstack-experimental/navigator/pkg/util	[no test files]
?   	github.com/jetstack-experimental/navigator/pkg/util/errors	[no test files]
ok  	github.com/jetstack-experimental/navigator/pkg/util/hash	0.032s
make: *** [Makefile:84: go_test] Error 2

With go version go1.8.4 linux/amd64

I left one or two additional questions and comments above.

Please answer or address at your discretion and then merge.

@@ -30,25 +30,21 @@ required = [
]

[[constraint]]
name = "github.com/Sirupsen/logrus"
revision = "v0.6.2-10-g51fe59a"
Copy link
Member

Choose a reason for hiding this comment

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

❓ I guess this is because we've switched to glog in navigator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - this was just a constraint since we removed use of logrus (the package itself wasn't actually depended upon since before this PR)

name = "k8s.io/client-go"
branch = "master"
branch = "release-5.0"
Copy link
Member

Choose a reason for hiding this comment

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

❓ Is there any advantage to using a version directive here? Will the release branch be updated with patch releases etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the release branches are updated. We'll need to run dep ensure -update periodically to re-vendor those changes.

$(BINDIR)/client-gen \
$(BINDIR)/lister-gen \
$(BINDIR)/informer-gen
touch $@
Copy link
Member

Choose a reason for hiding this comment

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

❓ So we no longer have to compile these binaries? Where do they get compiled now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They now get compiled as part of the new script in code-generator. See: kubernetes/kubernetes#52186

clientset "github.com/jetstack-experimental/navigator/pkg/client/clientset_generated/internalclientset"
informers "github.com/jetstack-experimental/navigator/pkg/client/informers_generated/internalversion"
clientset "github.com/jetstack-experimental/navigator/pkg/client/clientset/internalversion"
informers "github.com/jetstack-experimental/navigator/pkg/client/informers/internalversion"
Copy link
Member

Choose a reason for hiding this comment

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

❓ So how do we decide whether to use the internalversion or the versioned APIs? I guess I can see why the API server its self should use the internal versions, but why shouldn't the controller also use the internal APIs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Internal types should only be used within the API machinery for the apiserver, or if for some reason you need to convert between two external versions. That said, our controller should be built against one and only one version of the API, so there should basically never be a requirement to convert locally.

The controller shouldn't use the internal types for a number of reasons:

  • These types can change, breaking compatibility.
  • If we were to use the internal types, we'd then need to convert back into a versioned type in order to submit it back to the API server. We'd also need to convert to the internal version clientside too.
  • I'd question what we have to gain from trying to do this
  • It's also against all best practices for this sort of stuff, and would be a departure from how it is done within the k8s codebase. I can't recall an issue or justification for this decision, but I'm certain there is one with good reason.

There are a number of other potential complexities in doing this, and @dippynark and I did discuss it recently. I've managed to forget most of our thoughts on it though now! I will update here if they come back to me 😄

BINDIR=${REPO_ROOT}/bin
HACKDIR=${HACKDIR:-hack}
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
Copy link
Member

Choose a reason for hiding this comment

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

❓ I can't quite figure out what this is doing? Does it need an explanatory comment or is this copied over from Kubernetes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's copied over from the Kubernetes codebase. Roughly:

  • Set CODEGEN_PKG to CODEGEN_PKG if it is already set
  • Otherwise, cd into the root of the repo (SCRIPT_ROOT) and attempt to list ./vendor/k8s.io/code-generator if it exists, piping errors to /dev/null. If this command is successful, ./vendor/k8s.io/code-generator is printed to stdout from ls, thus CODEGEN_PKG becomes ./vendor/k8s.io/code-generator.
  • Otherwise, return ../code-generator. This final step is to deal with the case where our project is located within $GOPATH/src/k8s.io (or k8s.io/kubernetes/staging/src/k8s.io/). I copied this from the sample-controller project, hence this extra condition 😄

The script itself will error regardless if this path is set incorrectly, so I'm not too bothered about falling back to a directory that likely doesn't exist.

@wallrj
Copy link
Member

wallrj commented Oct 20, 2017

Ah ignore me:

I checked out the branch and ran dep ensure -v --dry-run --no-vendor. It reports:
Gopkg.lock was not up to date
I ran make all and got the following error:

There were some lingering files frrom my cassandra work.

@munnerz
Copy link
Contributor Author

munnerz commented Oct 22, 2017

Thanks for the review @wallrj - I've responded to your comments above.

Running dep ensure -v --dry-run --no-vendor locally I get: Gopkg.lock was already in sync with imports and Gopkg.toml. I guess whatever changes you had locally changed that 😄

@munnerz munnerz merged commit 35da950 into master Oct 22, 2017
@munnerz munnerz deleted the update-deps branch October 24, 2017 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants