Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

dep does not import kubernetes/client-go correctly #1207

Closed
beeradb opened this issue Sep 22, 2017 · 11 comments
Closed

dep does not import kubernetes/client-go correctly #1207

beeradb opened this issue Sep 22, 2017 · 11 comments

Comments

@beeradb
Copy link

beeradb commented Sep 22, 2017

What version of dep are you using (dep version)?

0.3.1

What dep command did you run?

Dep does not seem to import kubernetes/client-go code correctly. After stubbing my toe a bit on this with more complex examples, I decided to simplify and see if I could get it working with the very basic example code at https://github.com/kubernetes/client-go/blob/release-4.0/examples/in-cluster-client-configuration/main.go

I used the following Gopkg.toml file:

[[constraint]]
  name = "k8s.io/client-go"
  version = "4.0.0"

After getting the code in place and running dep ensure, I get the following errors when trying to compile the code:

# github.com/drud/site-manager/vendor/k8s.io/client-go/tools/clientcmd/api
vendor/k8s.io/client-go/tools/clientcmd/api/register.go:35:11: cannot use Config literal (type *Config) as type runtime.Object in argument to scheme.AddKnownTypes:
	*Config does not implement runtime.Object (missing DeepCopyObject method)
# github.com/drud/site-manager/vendor/k8s.io/client-go/pkg/apis/authentication
vendor/k8s.io/client-go/pkg/apis/authentication/register.go:47:16: cannot use TokenReview literal (type *TokenReview) as type runtime.Object in argument to scheme.AddKnownTypes:
	*TokenReview does not implement runtime.Object (missing DeepCopyObject method)

<a few hundred similar lines>

I also tried with this additional constraint, which I've seen listed as required in a few different places. I had similar (nonworking) results.

[[override]]
  name = "k8s.io/apimachinery"
  branch = "version-1.7"

Originally I was thinking client-go or one of it's dependencies was just broken, so I decided to give it a try with glide. I was able to get the exammple working with the following glide.yaml:

package: github.com/some/project
import:
- package: k8s.io/client-go
  version: v4.0.0

And finally, I'm not sure if they are useful here, but this is the result of dep hash-inputs:

-CONSTRAINTS-
k8s.io/client-go
svc-^4.0.0
-IMPORTS/REQS-
k8s.io/apimachinery/pkg/api/errors
k8s.io/apimachinery/pkg/apis/meta/v1
k8s.io/client-go/kubernetes
k8s.io/client-go/rest
-IGNORES-
-OVERRIDES-
-ANALYZER-
dep
1

I'm happy to provide the .lock files generated by both dep and glide if that would be helpful. This seems like it may be related to #1124.

Thanks for all the effort going into making dep awesome!

@sdboyer
Copy link
Member

sdboyer commented Oct 1, 2017

hi! and ugh, sorry for slow response - i'd flipped a switch in my mind that said "this is subsumed by #1124, and doesn't need to be addressed separately." and, while i expect that a satisfactory solution to #1124 would result in this not being a problem, this should still be able to be addressed today.

it's quite likely that your issue is with some dependency of k8s.io/client-go - indeed, possibly k8s.io/apimachinery. the [[constraint]] you added on it won't have any effect unless it's a direct dependency of your own project. but, hard to be sure, so yeah - if you could provide the Gopkg.lock (and contrast with the glide.lock that did work), that'd be super helpful 😄

@cristiamu
Copy link

Hi, I have this same issue. I tried adding the constraint for apimachinnery in the toml file, and update the lock file to the right branch/revision, but it did not work either. I've attached the original files generated by dep.

Gopkg.lock.txt
Gopkg.toml.txt

@carycodes
Copy link

As commented in kubernetes/client-go#298 ,

[[override]]
  name = "github.com/ugorji/go"
  revision = "8c0409fcbb70099c748d71f714529204975f6c3f"

in Gopkg.toml makes dep ensure pull the right files. I had this same problem and that solution worked for me.

@cristiamu
Copy link

Thanks, that worked for me.

@munnerz
Copy link

munnerz commented Nov 20, 2017

Hi all - I've created a little tool 'godep-to-dep' to try and make this easier/fix it upstream https://github.com/munnerz/godep-to-dep

If we can integrate this tool with our release process, we should be able to ship Gopkg.toml files out of the box.

@ghost
Copy link

ghost commented Dec 27, 2017

v6.0.0 appears to be working via dep for me now, not sure if it's by design or luck.

[[constraint]]
  name = "k8s.io/client-go"
  version = "v6.0.0"

@carolynvs
Copy link
Collaborator

It's because they swapped out ugorji for a different library. 😀

@diclophis
Copy link

diclophis commented May 4, 2018

What is the current status of this issue?

I am currently getting this error trying to use dep to install k8s.io/client-go/tools/clientcmd

See below:

dep ensure -add k8s.io/client-go/tools/clientcmd
Fetching sources...

Failed to add the dependencies:

  ✗ could not infer project root from dependency path: k8s.io/client-go/tools/clientcmd: unable to deduce repository and source type for "k8s.io/client-go/tools/clientcmd": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/client-go/tools/clientcmd?go-get=1": Get https://k8s.io/client-go/tools/clientcmd?go-get=1: net/http: TLS handshake timeout

adding dependencies failed

See also:

dep ensure -add k8s.io/client-go/tools/clientcmd.git
Fetching sources...

Failed to add the dependencies:

  ✗ failed to fetch source for k8s.io/client-go/tools/clientcmd.git: no valid source could be created: 
	failed to set up sources from the following URLs:
https://k8s.io/client-go/tools/clientcmd.git
: remote repository at https://k8s.io/client-go/tools/clientcmd.git does not exist, or is inaccessible: fatal: repository 'https://kubernetes.io/client-go/tools/clientcmd.git/' not found
: exit status 128
	failed to set up sources from the following URLs:
ssh://k8s.io/client-go/tools/clientcmd.git
: remote repository at ssh://k8s.io/client-go/tools/clientcmd.git does not exist, or is inaccessible: ssh: connect to host k8s.io port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
: exit status 128
	failed to set up sources from the following URLs:
git://k8s.io/client-go/tools/clientcmd.git
: remote repository at git://k8s.io/client-go/tools/clientcmd.git does not exist, or is inaccessible: fatal: unable to connect to k8s.io:
k8s.io[0: 23.236.58.218]: errno=Operation timed out

: exit status 128
	failed to set up sources from the following URLs:
http://k8s.io/client-go/tools/clientcmd.git
: remote repository at http://k8s.io/client-go/tools/clientcmd.git does not exist, or is inaccessible: fatal: repository 'https://kubernetes.io/client-go/tools/clientcmd.git/' not found
: exit status 128

adding dependencies failed

@atombender
Copy link

atombender commented Jun 9, 2018

The above workarounds don't seem to work these days because of #1306. Ignore me, v7.0.0 actually moves the packages around a lot, and the way dep works by sniffing imports meant that it was actually complaining about my imports.

@munnerz
Copy link

munnerz commented Jun 9, 2018 via email

@atombender
Copy link

@munnerz Thanks, you're right. I edited my comment after I realized that I was referencing packages that had been moved. (I've never liked Dep's behaviour, where it reads your imports to determine your dependencies, as opposed to requiring explicit declarations in Gopkg.toml. Because it should at least be able to give me an understandable error message, and tell me which files tried to import the non-existent package.)

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

No branches or pull requests

9 participants