Skip to content

segmentation violation code when I run it for minikube (works fine for real kubernetes clusters) #197

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

Closed
medyagh opened this issue May 20, 2017 · 9 comments

Comments

@medyagh
Copy link
Member

medyagh commented May 20, 2017

When I run this code for a real kubernetes cluster it works fine, but when I run it for minkube context I get this error:

panic: runtime error: invalid memory address or nil pointer dereference
signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x126204b]

To make sure it is not related to kuberentes version, I made my minikube to start with same version as my kuberentes (1.5.1)

here are my kubectl version

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:57:05Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"linux/amd64"}

Here is part of the code that throws error:

	pods, err := Clientset.CoreV1().Pods(lib.Cfg.Namespace).List(v1.ListOptions{})
	if err != nil {
		lib.Log.Error("error:", err)
		panic(err.Error())
	}

and here is how I can get my kubeconfig and clientset

	loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
	configOverrides := &clientcmd.ConfigOverrides{}
	kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
	config, err := kubeConfig.ClientConfig()
	if err != nil {
		return kubernetes.Clientset{}, errors.New("Failed loading client config")
	}
	clientset, err := kubernetes.NewForConfig(config)

another information that might be useful, I run my code in a docker container and I mount the .kube/config to the container (which works for real clusters but not for minikube)

@medyagh medyagh changed the title segmentation violation code when I run it for minikube segmentation violation code when I run it for minikube (works fine for real kubernetes clusters) May 21, 2017
@iordaniordanov
Copy link

iordaniordanov commented May 26, 2017

I'm experiencing the same issue with Pods("").List()

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x819f98]

I'm using a config for remote cluster. The problem occurs only for List(at least this what I've found). Getting a certain Pod info works fine.
The interesting thing is that right at the beginning the code was working fine(copy paste from examples/out-of-cluster). Now List just refuses to run.
I'm running the code directly on my PC(64bit Linux)
Go version go version go1.8.3 linux/amd64

@owenhaynes
Copy link

owenhaynes commented May 26, 2017

Getting this with secrets as well.

Go 1.8.
client-go v3.0.0-beta.0
kubernetes: 1.6.4

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x916a08]

goroutine 171 [running]:
/vendor/golang.org/x/net/http2.(*pipe).Read(0xc4209e4028, 0xc42083e000, 0x800, 0x2000, 0x0, 0x0, 0x0)
	//vendor/golang.org/x/net/http2/pipe.go:53 +0xa8
/vendor/golang.org/x/net/http2.transportResponseBody.Read(0xc4209e4000, 0xc42083e000, 0x800, 0x2000, 0x0, 0x0, 0x0)
	//vendor/golang.org/x/net/http2/transport.go:1588 +0xae
io.(*LimitedReader).Read(0xc4208d76c0, 0xc42083e000, 0x2000, 0x2000, 0x1530920, 0xc4208696e0, 0xc4209b0c60)
	/usr/local/go/src/io/io.go:436 +0x6c
io/ioutil.devNull.ReadFrom(0x0, 0x1f62480, 0xc4208d76c0, 0x14ab840, 0xc42074ad01, 0x7fafa57eb398)
	/usr/local/go/src/io/ioutil/ioutil.go:144 +0x85
io/ioutil.(*devNull).ReadFrom(0x1fe3b28, 0x1f62480, 0xc4208d76c0, 0x7fafa57eb398, 0x1fe3b28, 0x35c5b79b101)
	<autogenerated>:6 +0x61
io.copyBuffer(0x1f64580, 0x1fe3b28, 0x1f62480, 0xc4208d76c0, 0x0, 0x0, 0x0, 0x14ed560, 0x0, 0x7fafa57eb348)
	/usr/local/go/src/io/io.go:384 +0x2cb
io.Copy(0x1f64580, 0x1fe3b28, 0x1f62480, 0xc4208d76c0, 0xc4209e4000, 0x16fecd8, 0xc42040e100)
	/usr/local/go/src/io/io.go:360 +0x68
/vendor/k8s.io/client-go/rest.(*Request).request.func2.1(0xc420781560)
	//vendor/k8s.io/client-go/rest/request.go:852 +0xe9
/vendor/k8s.io/client-go/rest.(*Request).request.func2(0xc420781560, 0xc42077c540, 0xa, 0xc42076a000, 0xc42077c610, 0xc420386e00, 0xc4208d2fc0, 0xd8, 0x1)
	//vendor/k8s.io/client-go/rest/request.go:873 +0xe0
/vendor/k8s.io/client-go/rest.(*Request).request(0xc42076a000, 0xc42077c610, 0x0, 0x0)
	//vendor/k8s.io/client-go/rest/request.go:874 +0x3ea
/vendor/k8s.io/client-go/rest.(*Request).Do(0xc42076a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	//vendor/k8s.io/client-go/rest/request.go:895 +0xc0
/vendor/k8s.io/client-go/kubernetes/typed/core/v1.(*secrets).List(0xc4208d62a0, 0x0, 0x0, 0x0, 0x0, 0xc42031f980, 0x7e, 0x0, 0x0, 0x0, ...)
	//vendor/k8s.io/client-go/kubernetes/typed/core/v1/secret.go:128 +0x13a
client.CoreV1().Secrets(namespace).List(v1Meta.ListOptions{LabelSelector: selector.String()})

@ericchiang
Copy link
Contributor

@owenhaynes your panic looks like golang/go#20501

@iordaniordanov and @medyagh please including the full stack trace of the program when it panics and the version of transitive dependencies (e.g. what version is golang.org/x/net?). Just posting the top level error isn't enough. All nil pointer panic look the same and the stack trace is the actually actionable thing.

@owenhaynes
Copy link

@ericchiang cheers for that reverting x/net worked. Never thought to look at x/net

@iordaniordanov
Copy link

@ericchiang, sry for that. Will compare my trace with golang/go#20501 and will provide an update tomorrow

@iordaniordanov
Copy link

@ericchiang, my trace is like the one mentioned in golang/go#20501

@iordaniordanov
Copy link

iordaniordanov commented May 29, 2017

Sorry, but how should I fix the issue for myself? I've noticed the new code linked there, but I cannot find this file(pipe.go). I checked in the $GOROOT/src/vendor/golang_org/x/net/http2/ but there is no pipe.go file there
EDIT: Forget about this. I found the file and fixed it. My question is what is the generic way to fix the issue. I mean I cannot go and edit the src code on every machine my service is installed.

@ericchiang
Copy link
Contributor

@iordaniordanov you need to update your vendored copy of golang.org/x/net/http2. Please see the instructions in INSTALL.md https://github.com/kubernetes/client-go/blob/master/INSTALL.md

Particularly the glide instructions tell you how to pin to a vendored version that client-go doesn't request, though by the look of it, no tagged versions of client-go actually request the broken golang.org/x/net/http versions.

@caesarxuchao
Copy link
Member

Thanks for the solution! I'm closing the issue.

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

5 participants