kubernetes / api

The canonical location of the Kubernetes API definition.
Apache License 2.0
652 stars 433 forks source link

Invalid receiver type *List (List is an interface type) #5

Closed paralin closed 6 years ago

paralin commented 7 years ago

I'm continuously running into this error:

# k8s.io/api/core/v1
../../../k8s.io/api/core/v1/generated.pb.go:513:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:514:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:515:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:4177:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:4187:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:11017:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:13991:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/generated.pb.go:26053:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/zz_generated.deepcopy.go:2678:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/zz_generated.deepcopy.go:2693:6: invalid receiver type *List (List is an interface type)
../../../k8s.io/api/core/v1/zz_generated.deepcopy.go:2693:6: too many errors

metav1.List is an interface, you can't have a *List. Why is this even a thing? What versions can I revert to to fix this?

markns commented 7 years ago

This set of versions works for me:

# Kubernetes client
- package: k8s.io/client-go
  version: v4.0.0
- package: k8s.io/apimachinery
  version: release-1.7
- package: k8s.io/apiextensions-apiserver
  version: release-1.7
- package: k8s.io/api
  version: 4b8fc5be9b77d91bbb6525d18591c43699a2b4e5

... and by "works", I mean compiles

thomastaylor312 commented 6 years ago

If you are using dep, you need to use an override like this:

[[override]]
  name="k8s.io/api"
  revision="4b8fc5be9b77d91bbb6525d18591c43699a2b4e5"
[[override]]
  name = "k8s.io/apimachinery"
  revision = "1fd2e63a9a370677308a42f24fd40c86438afddf"
vijaykatam commented 6 years ago

For dep the following override is needed based on https://github.com/kubernetes/client-go/issues/298

[[override]]
  name = "github.com/ugorji/go"
  revision = "8c0409fcbb70099c748d71f714529204975f6c3f"
idealhack commented 6 years ago

Hi folks, 4b8fc5be9b77d91bbb6525d18591c43699a2b4e5 compiles. But I need package "k8s.io/api/apps/v1beta2" (because I need to use the StatefulSet), which was added after this version. How do I find a suitable version?

thomastaylor312 commented 6 years ago

@idealhack The way I have done it is to use the version of client-go you need (5.0.0 in this case) and then look at its Godeps to see what versions they are using there. That generally works for me

idealhack commented 6 years ago

@thomastaylor312 Thank you! So a match (newer) version of client-go will do it. I’ve saw the maintainer released v5.0.0 10 hours ago.

Update: I'm using kubernetes-1.8.1 for client-go, api, apimachinery now. Maybe use a same tag is better as they come from the same upstream.

gaurav-dalvi commented 6 years ago

I get following errors when i vendor in client-go, apimachinery and api of kubernetes-1.8.1 tag.

k8s.io/client-go/tools/clientcmd/overrides.go:122:3: invalid operation: flags (variable of type <company git>/<project>/vendor/github.com/spf13/pflag.FlagSet) has no field or method StringArrayVarP
/k8s.io/client-go/util/flowcontrol/throttle.go:59:2: Clock not declared by package ratelimit
k8s.io/client-go/util/flowcontrol/throttle.go:65:13: NewBucketWithRateAndClock not declared by package ratelimit

Any help would be appreciated.

gaurav-dalvi commented 6 years ago

client go uses spf13/pflag, our code does not use that. I dont see this spf13/pflag package in our Gopkg.toml file.

thirteenmans commented 6 years ago

I had same issue. And I find this may depend on api and apimachinery version. I use as below: cd apimachinery && git checkout release-1.7 cd api && git checkout master go build ./... I will get the same issue.

Then I tried the following combination: apimachinery: master && api: master apimachinery: release-1.9 && api: master apimachinery: release-1.8 && api: master They are all can build successfully!

So, I suggest that try to use apimachinery version >= release-1.8 with api.

fejta-bot commented 6 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 6 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten /remove-lifecycle stale

fejta-bot commented 6 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close