{"action":"created","comment":{"url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments/73588382","id":73588382,"diff_hunk":"@@ -0,0 +1,234 @@\n+/*\n+Copyright 2016 The Kubernetes Authors All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package nodeenv\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"reflect\"\n+\n+\t\"github.com/golang/glog\"\n+\n+\t\"k8s.io/kubernetes/pkg/admission\"\n+\t\"k8s.io/kubernetes/pkg/api\"\n+\t\"k8s.io/kubernetes/pkg/api/errors\"\n+\t\"k8s.io/kubernetes/pkg/client/cache\"\n+\tclientset \"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset\"\n+\t\"k8s.io/kubernetes/pkg/runtime\"\n+\t\"k8s.io/kubernetes/pkg/util/yaml\"\n+\t\"k8s.io/kubernetes/pkg/watch\"\n+)\n+\n+func init() {\n+\tadmission.RegisterPlugin(\"PodNodeEnvironment\", func(client clientset.Interface, config io.Reader) (admission.Interface, error) {\n+\t\tpluginConfig := readConfig(config)\n+\t\tplugin := NewPodNodeEnvironment(client, pluginConfig.PodNodeEnvironmentPluginConfig)\n+\t\tplugin.reflector.Run()\n+\t\treturn plugin, nil\n+\t})\n+}\n+\n+// podNodeEnvironment is an implementation of admission.Interface.\n+type podNodeEnvironment struct {\n+\t*admission.Handler\n+\tclient    clientset.Interface\n+\tstore     cache.Store\n+\treflector *cache.Reflector\n+\t// global default tolerations in a cluster, If a namespace is\n+\t// not assigned tolerations, it gets this by default.\n+\tclusterDefaultTolerations []api.Toleration\n+}\n+\n+type pluginConfig struct {\n+\tPodNodeEnvironmentPluginConfig []api.Toleration\n+}\n+\n+// readConfig reads default value of clusterDefaultTolerations\n+// from the file provided with --admission-control-config-file\n+// If the file is not supplied, it defaults to \"\"\n+// The format in a file:\n+// podNodeEnvironmentPluginConfig:\n+//  clusterDefaultTolerations: <tolerations>\n+func readConfig(config io.Reader) *pluginConfig {\n+\tdefaultConfig := &pluginConfig{}\n+\tif config == nil || reflect.ValueOf(config).IsNil() {\n+\t\treturn defaultConfig\n+\t}\n+\td := yaml.NewYAMLOrJSONDecoder(config, 4096)\n+\tfor {\n+\t\tif err := d.Decode(defaultConfig); err != nil {\n+\t\t\tif err != io.EOF {\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t}\n+\t\tbreak\n+\t}\n+\treturn defaultConfig\n+}\n+\n+// Admit merges pod's and its namespace tolerations.\n+func (p *podNodeEnvironment) Admit(a admission.Attributes) error {\n+\tresource := a.GetResource().GroupResource()\n+\tif resource != api.Resource(\"pods\") {\n+\t\treturn nil\n+\t}\n+\tif a.GetSubresource() != \"\" {\n+\t\t// only run the checks below on pods proper and not subresources\n+\t\treturn nil\n+\t}\n+\n+\tobj := a.GetObject()\n+\tpod, ok := obj.(*api.Pod)\n+\tif !ok {\n+\t\tglog.Errorf(\"expected pod but got %s\", a.GetKind().Kind)\n+\t\treturn nil\n+\t}\n+\n+\tnsName := a.GetNamespace()\n+\tvar namespace *api.Namespace\n+\n+\tnamespaceObj, exists, err := p.store.Get(&api.Namespace{","path":"plugin/pkg/admission/nodeenv/admission.go","position":105,"original_position":105,"commit_id":"6c163515e7ca1030e0e3f7ac97adc1111c6eecfa","original_commit_id":"6c163515e7ca1030e0e3f7ac97adc1111c6eecfa","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"body":"Also add the wait for ready checks ","created_at":"2016-08-04T19:35:56Z","updated_at":"2016-08-04T19:35:56Z","html_url":"https://github.com/aveshagarwal/kubernetes/pull/6#discussion_r73588382","pull_request_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments/73588382"},"html":{"href":"https://github.com/aveshagarwal/kubernetes/pull/6#discussion_r73588382"},"pull_request":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6","id":80079789,"html_url":"https://github.com/aveshagarwal/kubernetes/pull/6","diff_url":"https://github.com/aveshagarwal/kubernetes/pull/6.diff","patch_url":"https://github.com/aveshagarwal/kubernetes/pull/6.patch","issue_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/6","number":6,"state":"open","locked":false,"title":"[WIP]: Project node selector feature by using taints and tolerations","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"body":"I have to really polish/refactor/test properly. But it compiles and unit tests pass.","created_at":"2016-08-04T13:39:29Z","updated_at":"2016-08-04T19:35:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a117483adb64e21c528442df266ec750a9e26e1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6/commits","review_comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6/comments","review_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/6/comments","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/6c163515e7ca1030e0e3f7ac97adc1111c6eecfa","head":{"label":"aveshagarwal:master-project-node-selector-taints-tolerations","ref":"master-project-node-selector-taints-tolerations","sha":"6c163515e7ca1030e0e3f7ac97adc1111c6eecfa","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"repo":{"id":32509925,"name":"kubernetes","full_name":"aveshagarwal/kubernetes","owner":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aveshagarwal/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/aveshagarwal/kubernetes","forks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/forks","keys_url":"https://api.github.com/repos/aveshagarwal/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aveshagarwal/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aveshagarwal/kubernetes/teams","hooks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/events","assignees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/aveshagarwal/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/tags","blobs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/aveshagarwal/kubernetes/languages","stargazers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscription","commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/aveshagarwal/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aveshagarwal/kubernetes/merges","archive_url":"https://api.github.com/repos/aveshagarwal/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aveshagarwal/kubernetes/downloads","issues_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/aveshagarwal/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/aveshagarwal/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aveshagarwal/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/aveshagarwal/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/deployments","created_at":"2015-03-19T08:38:39Z","updated_at":"2016-01-13T15:56:58Z","pushed_at":"2016-08-04T13:39:29Z","git_url":"git://github.com/aveshagarwal/kubernetes.git","ssh_url":"git@github.com:aveshagarwal/kubernetes.git","clone_url":"https://github.com/aveshagarwal/kubernetes.git","svn_url":"https://github.com/aveshagarwal/kubernetes","homepage":"http://kubernetes.io","size":296138,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"aveshagarwal:master","ref":"master","sha":"63602348a46dae777038be34470c0d7d025420fe","user":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"repo":{"id":32509925,"name":"kubernetes","full_name":"aveshagarwal/kubernetes","owner":{"login":"aveshagarwal","id":3596412,"avatar_url":"https://avatars.githubusercontent.com/u/3596412?v=3","gravatar_id":"","url":"https://api.github.com/users/aveshagarwal","html_url":"https://github.com/aveshagarwal","followers_url":"https://api.github.com/users/aveshagarwal/followers","following_url":"https://api.github.com/users/aveshagarwal/following{/other_user}","gists_url":"https://api.github.com/users/aveshagarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/aveshagarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aveshagarwal/subscriptions","organizations_url":"https://api.github.com/users/aveshagarwal/orgs","repos_url":"https://api.github.com/users/aveshagarwal/repos","events_url":"https://api.github.com/users/aveshagarwal/events{/privacy}","received_events_url":"https://api.github.com/users/aveshagarwal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aveshagarwal/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/aveshagarwal/kubernetes","forks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/forks","keys_url":"https://api.github.com/repos/aveshagarwal/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aveshagarwal/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aveshagarwal/kubernetes/teams","hooks_url":"https://api.github.com/repos/aveshagarwal/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/aveshagarwal/kubernetes/events","assignees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/aveshagarwal/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/tags","blobs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/aveshagarwal/kubernetes/languages","stargazers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/aveshagarwal/kubernetes/subscription","commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/aveshagarwal/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/aveshagarwal/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/aveshagarwal/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aveshagarwal/kubernetes/merges","archive_url":"https://api.github.com/repos/aveshagarwal/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aveshagarwal/kubernetes/downloads","issues_url":"https://api.github.com/repos/aveshagarwal/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/aveshagarwal/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/aveshagarwal/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aveshagarwal/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/aveshagarwal/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/aveshagarwal/kubernetes/deployments","created_at":"2015-03-19T08:38:39Z","updated_at":"2016-01-13T15:56:58Z","pushed_at":"2016-08-04T13:39:29Z","git_url":"git://github.com/aveshagarwal/kubernetes.git","ssh_url":"git@github.com:aveshagarwal/kubernetes.git","clone_url":"https://github.com/aveshagarwal/kubernetes.git","svn_url":"https://github.com/aveshagarwal/kubernetes","homepage":"http://kubernetes.io","size":296138,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6"},"html":{"href":"https://github.com/aveshagarwal/kubernetes/pull/6"},"issue":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/6"},"comments":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/aveshagarwal/kubernetes/statuses/6c163515e7ca1030e0e3f7ac97adc1111c6eecfa"}}}}
{"actor":{"display_login":"derekwaynecarr"}}