Hide Forgot
Description of problem: oc project meets panic "invalid memory address or nil pointer dereference" when the kube config is abnormal. E.g. This can be reproduced via `oc project` inside pod Version-Release number of selected component (if applicable): oc v1.3.0-alpha.3+0eb9cf4 kubernetes v1.3.0+507d3a7 features: Basic-Auth GSSAPI Kerberos SPNEGO How reproducible: Always Steps to Reproduce: 1. Create pod which contains oc, e.g. via openshift/origin image: $ oc run mydc --image=openshift/origin --command=true sleep 1d 2. Enter into pod shell 1> $ oc rsh mydc-1-vnt0d sh-4.2$ Do following checks: 2> sh-4.2$ oc version oc v1.3.0-alpha.3+0eb9cf4 kubernetes v1.3.0+507d3a7 features: Basic-Auth GSSAPI Kerberos SPNEGO ... 3> sh-4.2$ oc config view apiVersion: v1 clusters: [] contexts: [] current-context: "" kind: Config preferences: {} users: [] 4> sh-4.2$ oc project panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x59749e] goroutine 1 [running]: panic(0x419fd20, 0xc820012090) /usr/local/go/src/runtime/panic.go:481 +0x3e6 github.com/openshift/origin/pkg/cmd/cli/cmd.ProjectOptions.RunProject(0x0, 0x0, 0x0, 0x0, 0x0, 0xc8203f6ed0, 0xc8203f6f00, 0xc8203f6f30, 0xc8203f6f60, 0x0, ...) /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/pkg/cmd/cli/cmd/project.go:126 +0x26ce github.com/openshift/origin/pkg/cmd/cli/cmd.NewCmdProject.func1(0xc8208d18c0, 0x8056348, 0x0, 0x0) /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/pkg/cmd/cli/cmd/project.go:76 +0x1a3 github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).execute(0xc8208d18c0, 0x8056348, 0x0, 0x0, 0x0, 0x0) /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:603 +0x896 github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc8208ad200, 0xc8208d18c0, 0x0, 0x0) /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:689 +0x55c github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).Execute(0xc8208ad200, 0x0, 0x0) /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:648 +0x2d main.main() /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/cmd/openshift/openshift.go:33 +0x199 Actual results: 2. 4> Meet panic (note: the user inside a pod is serviceaccout "default") Expected results: 2. 4> Should not meet panic and give proper message Additional info:
Fixed in https://github.com/openshift/origin/pull/10521
Checked with oc v1.3.0-alpha.3+670926d, inside pod, now `oc project` does not panic. Instead, it prompts "No project has been set. Pass a project name to make that the default." as it did under OS bash. Looks good.