{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/client-go/issues/239","repository_url":"https://api.github.com/repos/kubernetes/client-go","labels_url":"https://api.github.com/repos/kubernetes/client-go/issues/239/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/client-go/issues/239/comments","events_url":"https://api.github.com/repos/kubernetes/client-go/issues/239/events","html_url":"https://github.com/kubernetes/client-go/issues/239","id":242169879,"number":239,"title":"client-go broke for 1.6 ","user":{"login":"medyagh","id":4564227,"avatar_url":"https://avatars0.githubusercontent.com/u/4564227?v=3","gravatar_id":"","url":"https://api.github.com/users/medyagh","html_url":"https://github.com/medyagh","followers_url":"https://api.github.com/users/medyagh/followers","following_url":"https://api.github.com/users/medyagh/following{/other_user}","gists_url":"https://api.github.com/users/medyagh/gists{/gist_id}","starred_url":"https://api.github.com/users/medyagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medyagh/subscriptions","organizations_url":"https://api.github.com/users/medyagh/orgs","repos_url":"https://api.github.com/users/medyagh/repos","events_url":"https://api.github.com/users/medyagh/events{/privacy}","received_events_url":"https://api.github.com/users/medyagh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-07-11T20:14:26Z","updated_at":"2017-07-11T20:26:09Z","closed_at":null,"body":"Hi I wanted to upgrade [K8Guard](github.com/k8guard) (an auditing system for kubernetes) to work with k8s 1.6. \r\n\r\nwe were using client-go `v2.0.0-alpha.1` with  `k8s 1.5`\r\nI did notice the API calls have changed and I updated client-go to `v3.0.0-beta.0`\r\n\r\nand I changed my code to look like this\r\n```\r\nimport (\r\n\t\"strings\"\r\n\t\"io/ioutil\"\r\n\t\"encoding/json\"\r\n\tmeta \"k8s.io/apimachinery/pkg/apis/meta/v1\"\r\n\tlib \"github.com/k8guard/k8guardlibs\"\r\n\t\"k8s.io/client-go/pkg/apis/apps/v1beta1\"\r\n\t\"github.com/k8guard/k8guardlibs/messaging/kafka\"\r\n\t\"github.com/k8guard/k8guardlibs/violations\"\r\n\t\"github.com/k8guard/k8guard-discover/metrics\"\r\n\t\"github.com/prometheus/client_golang/prometheus\"\r\n)\r\n\r\nfunc GetAllDeployFromApi() []v1beta1.Deployment {\r\n\tdeploys, err := Clientset.AppsV1beta1().Deployments(lib.Cfg.Namespace).List(meta.ListOptions{})\r\n\tif err != nil {\r\n\t\tlib.Log.Error(\"error: \", err)\r\n\t\tpanic(err.Error())\r\n\t}\r\n\r\n\tif lib.Cfg.OutputPodsToFile == true {\r\n\t\tr, _ := json.Marshal(deploys.Items)\r\n\t\terr = ioutil.WriteFile(\"deployments.txt\", r, 0644)\r\n\t\tif err != nil {\r\n\t\t\tlib.Log.Error(\"error:\", err)\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\t}\r\n\tmetrics.Update(metrics.ALL_DEPLOYMENT_COUNT, len(deploys.Items))\r\n\treturn deploys.Items\r\n```\r\n\r\nfor previous version ( `v2.0.0-alpha.1` with 1.5 k8s) the code was this:\r\nhttps://github.com/k8guard/k8guard-discover/blob/cd95898cb406bba14bc327899e4309b0430f9843/discover/deployments.go\r\n\r\n```\r\npackage discover\r\n \r\nimport (\r\n    \"strings\"\r\n    \"io/ioutil\"\r\n    \"encoding/json\"\r\n    \"k8s.io/client-go/pkg/api/v1\"\r\n    lib \"github.com/k8guard/k8guardlibs\"\r\n    \"k8s.io/client-go/pkg/apis/extensions/v1beta1\"\r\n    \"github.com/k8guard/k8guardlibs/messaging/kafka\"\r\n    \"github.com/k8guard/k8guardlibs/violations\"\r\n    \"github.com/k8guard/k8guard-discover/metrics\"\r\n    \"github.com/prometheus/client_golang/prometheus\"\r\n)\r\n \r\nfunc GetAllDeployFromApi() []v1beta1.Deployment {\r\n    deploys, err := Clientset.Deployments(lib.Cfg.Namespace).List(v1.ListOptions{})\r\n    if err != nil {\r\n        lib.Log.Error(\"error: \", err)\r\n        panic(err.Error())\r\n    }\r\n \r\n    if (lib.Cfg.OutputPodsToFile == true) {\r\n        r, _ := json.Marshal(deploys.Items)\r\n        err = ioutil.WriteFile(\"deployments.txt\", r, 0644)\r\n        if err != nil {\r\n            lib.Log.Error(\"error:\", err)\r\n            panic(err)\r\n        }\r\n    }\r\n    metrics.Update(metrics.ALL_DEPLOYMENT_COUNT, len(deploys.Items))\r\n    return deploys.Items\r\n}\r\n```\r\n\r\n\r\nand the error I get is:\r\n\r\n```\r\n2017/07/11 20:07:18 [k8guard-discover-deployment-2727519787-fcb08/k4v1x7jbjT-000038] \"GET http://192.168.99.100:32243/deploys HTTP/1.1\" from 172.17.0.1:49460 - panic: runtime error: invalid memory address or nil pointer dereference\r\n2017/07/11 20:07:18 goroutine 94 [running]:\r\nruntime/debug.Stack(0xc420161600, 0x1f75260, 0xc4200d3b60)\r\n\t/usr/local/Cellar/go/1.8/libexec/src/runtime/debug/stack.go:24 +0x79\r\ngithub.com/k8guard/k8guard-discover/vendor/github.com/pressly/chi/middleware.Recoverer.func1.1(0xc420161600, 0x7f305859fdd0, 0xc4200fe7c0)\r\n\t/Users/z001r9y/go/src/github.com/k8guard/k8guard-discover/vendor/github.com/pressly/chi/middleware/recoverer.go:23 +0x82\r\npanic(0x14b2f00, 0x1fd28f0)\r\n\t/usr/local/Cellar/go/1.8/libexec/src/runtime/panic.go:489 +0x2cf\r\ngithub.com/k8guard/k8guard-discover/vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1.(*deployments).List(0xc42000af80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\r\n\t/Users/z001r9y/go/src/github.com/k8guard/k8guard-discover/vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go:141 +0x9b\r\ngithub.com/k8guard/k8guard-discover/discover.GetAllDeployFromApi(0xc42023eff0, 0x165a081, 0x12)\r\n\t/Users/z001r9y/go/src/github.com/k8guard/k8guard-discover/discover/deployments.go:17 +0x91\r\nmain.startHttpServer.func5(0x7f305859fdd0, 0xc4200fe7c0, 0xc420161700)\r\n\t/Users/z001r9y/go/src/github.com/k8guard/k8guard-discover/routes.go:80 +0xaa\r\nnet/http.HandlerFunc.ServeHTTP(0x16c0570, 0x7f305859fdd0, 0xc4200fe7c0, 0xc420161700)\r\n```"},"comment":{"url":"https://api.github.com/repos/kubernetes/client-go/issues/comments/314561245","html_url":"https://github.com/kubernetes/client-go/issues/239#issuecomment-314561245","issue_url":"https://api.github.com/repos/kubernetes/client-go/issues/239","id":314561245,"user":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars3.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"created_at":"2017-07-11T20:26:08Z","updated_at":"2017-07-11T20:26:08Z","body":"You should pass `*kubernetes.Clientset`, not `kubernetes.Clientset`. Then you wouldn't have to do the line `return kubernetes.Clientset{}, err`, which will cause the problem you observe if the error is ignored."}}
{"actor":{"display_login":"lavalamp"}}