{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26720196","id":26720196,"diff_hunk":"@@ -0,0 +1,102 @@\n+/*\n+Copyright 2014 Google Inc. 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 exec\n+\n+import (\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"path\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network\"\n+\tcmdexec \"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec\"\n+\t\"github.com/golang/glog\"\n+)\n+\n+type execNetworkPlugin struct {\n+\texecName string\n+\texecPath string\n+\thost     network.Host\n+}\n+\n+const (\n+\tinitCmd     = \"--init\"\n+\tsetUpCmd    = \"--setup\"\n+\ttearDownCmd = \"--teardown\"\n+\texecDir     = \"/usr/libexec/kubernetes/kubelet-plugins/net/exec/\"\n+)\n+\n+func ProbeNetworkPlugins() []network.NetworkPlugin {\n+\treturn ProbeNetworkPluginsWithExecDir(execDir)\n+}\n+\n+func ProbeNetworkPluginsWithExecDir(pluginDir string) []network.NetworkPlugin {\n+\texecPlugins := []network.NetworkPlugin{}\n+\n+\tfiles, _ := ioutil.ReadDir(pluginDir)\n+\tfor _, f := range files {\n+\t\t// only directories are counted as plugins\n+\t\t// and we expect pluginDir/dirname/dirname to be an executable\n+\t\tif f.IsDir() {\n+\t\t\texecPath := path.Join(pluginDir, f.Name())\n+\t\t\texecPlugins = append(execPlugins, &execNetworkPlugin{execName: f.Name(), execPath: execPath})\n+\t\t}\n+\t}\n+\treturn execPlugins\n+}\n+\n+func (plugin *execNetworkPlugin) Init(host network.Host) error {\n+\tplugin.host = host\n+\t// call the init script\n+\texecutable := path.Join(plugin.execPath, plugin.execName)\n+\tout, err := cmdexec.New().Command(executable, initCmd).CombinedOutput()\n+\tglog.V(5).Infof(\"Init 'exec' network plugin output: %s, %v\", string(out), err)\n+\treturn err\n+}\n+\n+func (plugin *execNetworkPlugin) Name() string {\n+\treturn plugin.execName\n+}\n+\n+func (plugin *execNetworkPlugin) Validate() error {","path":"pkg/kubelet/network/exec/exec.go","position":77,"original_position":77,"commit_id":"7560b24b11d6e4c934c0a58a4c56bea29e7684c7","original_commit_id":"7560b24b11d6e4c934c0a58a4c56bea29e7684c7","user":{"login":"thockin","id":5595220,"avatar_url":"https://avatars.githubusercontent.com/u/5595220?v=3","gravatar_id":"","url":"https://api.github.com/users/thockin","html_url":"https://github.com/thockin","followers_url":"https://api.github.com/users/thockin/followers","following_url":"https://api.github.com/users/thockin/following{/other_user}","gists_url":"https://api.github.com/users/thockin/gists{/gist_id}","starred_url":"https://api.github.com/users/thockin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thockin/subscriptions","organizations_url":"https://api.github.com/users/thockin/orgs","repos_url":"https://api.github.com/users/thockin/repos","events_url":"https://api.github.com/users/thockin/events{/privacy}","received_events_url":"https://api.github.com/users/thockin/received_events","type":"User","site_admin":false},"body":"Can we just fold Validation into Init()?  Less function on an interface makes me happy","created_at":"2015-03-19T00:06:52Z","updated_at":"2015-03-19T00:06:52Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069#discussion_r26720196","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26720196"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069#discussion_r26720196"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069","id":30515384,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5069","number":5069,"state":"open","locked":false,"title":"[WIP] southbound networking hooks in kubelet","user":{"login":"rajatchopra","id":982221,"avatar_url":"https://avatars.githubusercontent.com/u/982221?v=3","gravatar_id":"","url":"https://api.github.com/users/rajatchopra","html_url":"https://github.com/rajatchopra","followers_url":"https://api.github.com/users/rajatchopra/followers","following_url":"https://api.github.com/users/rajatchopra/following{/other_user}","gists_url":"https://api.github.com/users/rajatchopra/gists{/gist_id}","starred_url":"https://api.github.com/users/rajatchopra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajatchopra/subscriptions","organizations_url":"https://api.github.com/users/rajatchopra/orgs","repos_url":"https://api.github.com/users/rajatchopra/repos","events_url":"https://api.github.com/users/rajatchopra/events{/privacy}","received_events_url":"https://api.github.com/users/rajatchopra/received_events","type":"User","site_admin":false},"body":"Addresses the 'most agreed upon' hooks as desired in #3350.\r\nJust two hooks here in kubelet:\r\n\r\n - After pod infra container is launched (before other containers of the pod are launched)\r\n - Before pod infra container is deleted\r\n\r\nTrying to keep it minimal and totally decoupled so that plugins do not have to be compiled in kubernetes. To enable the plugin, just call kubelet with --network_plugin_name option. An appropriate scheme would have been to register the plugin with the apiserver, but because of lack of global config storage, we are going with the command line option for now. \r\nThe global config storage in apiserver is being addressed in this broader issue #1553.\r\n\r\nping @thockin @jainvipin @mrunalp @joeswaminathan \r\n","created_at":"2015-03-04T23:21:42Z","updated_at":"2015-03-19T00:06:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a145ad7a3c9681764eb9547e0b651052efd2729d","assignee":{"login":"thockin","id":5595220,"avatar_url":"https://avatars.githubusercontent.com/u/5595220?v=3","gravatar_id":"","url":"https://api.github.com/users/thockin","html_url":"https://github.com/thockin","followers_url":"https://api.github.com/users/thockin/followers","following_url":"https://api.github.com/users/thockin/following{/other_user}","gists_url":"https://api.github.com/users/thockin/gists{/gist_id}","starred_url":"https://api.github.com/users/thockin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thockin/subscriptions","organizations_url":"https://api.github.com/users/thockin/orgs","repos_url":"https://api.github.com/users/thockin/repos","events_url":"https://api.github.com/users/thockin/events{/privacy}","received_events_url":"https://api.github.com/users/thockin/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5069/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/7560b24b11d6e4c934c0a58a4c56bea29e7684c7","head":{"label":"rajatchopra:network_hooks","ref":"network_hooks","sha":"7560b24b11d6e4c934c0a58a4c56bea29e7684c7","user":{"login":"rajatchopra","id":982221,"avatar_url":"https://avatars.githubusercontent.com/u/982221?v=3","gravatar_id":"","url":"https://api.github.com/users/rajatchopra","html_url":"https://github.com/rajatchopra","followers_url":"https://api.github.com/users/rajatchopra/followers","following_url":"https://api.github.com/users/rajatchopra/following{/other_user}","gists_url":"https://api.github.com/users/rajatchopra/gists{/gist_id}","starred_url":"https://api.github.com/users/rajatchopra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajatchopra/subscriptions","organizations_url":"https://api.github.com/users/rajatchopra/orgs","repos_url":"https://api.github.com/users/rajatchopra/repos","events_url":"https://api.github.com/users/rajatchopra/events{/privacy}","received_events_url":"https://api.github.com/users/rajatchopra/received_events","type":"User","site_admin":false},"repo":{"id":22663851,"name":"kubernetes","full_name":"rajatchopra/kubernetes","owner":{"login":"rajatchopra","id":982221,"avatar_url":"https://avatars.githubusercontent.com/u/982221?v=3","gravatar_id":"","url":"https://api.github.com/users/rajatchopra","html_url":"https://github.com/rajatchopra","followers_url":"https://api.github.com/users/rajatchopra/followers","following_url":"https://api.github.com/users/rajatchopra/following{/other_user}","gists_url":"https://api.github.com/users/rajatchopra/gists{/gist_id}","starred_url":"https://api.github.com/users/rajatchopra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajatchopra/subscriptions","organizations_url":"https://api.github.com/users/rajatchopra/orgs","repos_url":"https://api.github.com/users/rajatchopra/repos","events_url":"https://api.github.com/users/rajatchopra/events{/privacy}","received_events_url":"https://api.github.com/users/rajatchopra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rajatchopra/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/rajatchopra/kubernetes","forks_url":"https://api.github.com/repos/rajatchopra/kubernetes/forks","keys_url":"https://api.github.com/repos/rajatchopra/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rajatchopra/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rajatchopra/kubernetes/teams","hooks_url":"https://api.github.com/repos/rajatchopra/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/rajatchopra/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/rajatchopra/kubernetes/events","assignees_url":"https://api.github.com/repos/rajatchopra/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/rajatchopra/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/rajatchopra/kubernetes/tags","blobs_url":"https://api.github.com/repos/rajatchopra/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rajatchopra/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rajatchopra/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/rajatchopra/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rajatchopra/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/rajatchopra/kubernetes/languages","stargazers_url":"https://api.github.com/repos/rajatchopra/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/rajatchopra/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/rajatchopra/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/rajatchopra/kubernetes/subscription","commits_url":"https://api.github.com/repos/rajatchopra/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/rajatchopra/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/rajatchopra/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/rajatchopra/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/rajatchopra/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/rajatchopra/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rajatchopra/kubernetes/merges","archive_url":"https://api.github.com/repos/rajatchopra/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rajatchopra/kubernetes/downloads","issues_url":"https://api.github.com/repos/rajatchopra/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/rajatchopra/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/rajatchopra/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/rajatchopra/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rajatchopra/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/rajatchopra/kubernetes/releases{/id}","created_at":"2014-08-06T00:14:36Z","updated_at":"2015-02-11T21:45:21Z","pushed_at":"2015-03-18T22:52:52Z","git_url":"git://github.com/rajatchopra/kubernetes.git","ssh_url":"git@github.com:rajatchopra/kubernetes.git","clone_url":"https://github.com/rajatchopra/kubernetes.git","svn_url":"https://github.com/rajatchopra/kubernetes","homepage":null,"size":36232,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"97b806e3a7a965c3674f39bcd15b337ff7b562a2","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-03-19T00:01:22Z","pushed_at":"2015-03-19T00:01:21Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":106370,"stargazers_count":6641,"watchers_count":6641,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1235,"mirror_url":null,"open_issues_count":765,"forks":1235,"open_issues":765,"watchers":6641,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5069"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5069"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5069/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5069/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/7560b24b11d6e4c934c0a58a4c56bea29e7684c7"}}}}