{"action":"created","comment":{"url":"https://api.github.com/repos/google/cadvisor/pulls/comments/57215239","id":57215239,"diff_hunk":"@@ -0,0 +1,339 @@\n+// Copyright 2016 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+// Handler for \"rkt\" containers.\n+package rkt\n+\n+import (\n+\t\"fmt\"\n+\t\"os\"\n+\t\"path\"\n+\t\"time\"\n+\n+\trktapi \"github.com/coreos/rkt/api/v1alpha\"\n+\t\"github.com/google/cadvisor/container\"\n+\t\"github.com/google/cadvisor/container/common\"\n+\t\"github.com/google/cadvisor/container/libcontainer\"\n+\t\"github.com/google/cadvisor/fs\"\n+\tinfo \"github.com/google/cadvisor/info/v1\"\n+\t\"github.com/google/cadvisor/utils\"\n+\t\"golang.org/x/net/context\"\n+\n+\t\"github.com/golang/glog\"\n+\t\"github.com/opencontainers/runc/libcontainer/cgroups\"\n+\tcgroupfs \"github.com/opencontainers/runc/libcontainer/cgroups/fs\"\n+\t\"github.com/opencontainers/runc/libcontainer/configs\"\n+)\n+\n+type rktContainerHandler struct {\n+\trktClient rktapi.PublicAPIClient\n+\t// Name of the container for this handler.\n+\tname               string\n+\tcgroupSubsystems   *libcontainer.CgroupSubsystems\n+\tmachineInfoFactory info.MachineInfoFactory\n+\n+\t// Absolute path to the cgroup hierarchies of this container.\n+\t// (e.g.: \"cpu\" -> \"/sys/fs/cgroup/cpu/test\")\n+\tcgroupPaths map[string]string\n+\n+\t// Manager of this container's cgroups.\n+\tcgroupManager cgroups.Manager\n+\n+\t// Whether this container has network isolation enabled.\n+\thasNetwork bool\n+\n+\tfsInfo         fs.FsInfo\n+\texternalMounts []common.Mount\n+\n+\trootFs string\n+\n+\tisPod bool\n+\n+\taliases []string\n+\n+\tpid int\n+\n+\trootfsStorageDir string\n+\n+\t// Filesystem handler.\n+\tfsHandler common.FsHandler\n+\n+\tignoreMetrics container.MetricSet\n+}\n+\n+func (self *rktContainerHandler) GetCgroupPaths() map[string]string {\n+\treturn self.cgroupPaths\n+}\n+\n+func (self *rktContainerHandler) GetMachineInfoFactory() info.MachineInfoFactory {\n+\treturn self.machineInfoFactory\n+}\n+\n+func (self *rktContainerHandler) GetName() string {\n+\treturn self.name\n+}\n+\n+func (self *rktContainerHandler) GetExternalMounts() []common.Mount {\n+\treturn self.externalMounts\n+}\n+\n+func (self *rktContainerHandler) HasNetwork() bool {\n+\treturn self.hasNetwork && !self.ignoreMetrics.Has(container.NetworkUsageMetrics)\n+}\n+\n+func (self *rktContainerHandler) HasFilesystem() bool {\n+\tif !self.ignoreMetrics.Has(container.DiskUsageMetrics) {\n+\t\treturn true\n+\t}\n+\treturn false\n+}\n+\n+func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPath string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) {\n+\taliases := make([]string, 1)\n+\tisPod := false\n+\n+\tparsed, err := parseName(name)\n+\tif err != nil {\n+\t\treturn nil, fmt.Errorf(\"this should be impossible!, new handler failing, but factory allowed, name = %s\", name)\n+\t}\n+\n+\t//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx\n+\tif parsed.Container == \"\" {\n+\t\tisPod = true\n+\t\taliases = append(aliases, \"rkt://\"+parsed.Pod)\n+\t} else {\n+\t\taliases = append(aliases, \"rkt://\"+parsed.Pod+\":\"+parsed.Container)\n+\t}\n+\n+\tpid := os.Getpid()\n+\tif parsed.Container == \"\" {\n+\t\tresp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{\n+\t\t\tId: parsed.Pod,\n+\t\t})\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t\tpid = int(resp.Pod.Pid)\n+\t} else {\n+\t\tglog.Infof(\"skipping as Container\")\n+\t}\n+\n+\tcgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)\n+\n+\tcHints, err := common.GetContainerHintsFromFile(*common.ArgContainerHints)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\t// Generate the equivalent cgroup manager for this container.\n+\tcgroupManager := &cgroupfs.Manager{\n+\t\tCgroups: &configs.Cgroup{\n+\t\t\tName: name,\n+\t\t},\n+\t\tPaths: cgroupPaths,\n+\t}\n+\n+\thasNetwork := false\n+\tif isPod {\n+\t\thasNetwork = true\n+\t}\n+\n+\t//SJP: unsure the point of this code, if it event does anything today?","path":"container/rkt/handler.go","position":null,"original_position":152,"commit_id":"4d0f8fafbe38aaca5ff05d65e61e9b4708c741df","original_commit_id":"206670a655ba587b6c794b1d238d6f1819ef69e8","user":{"login":"vishh","id":7063592,"avatar_url":"https://avatars.githubusercontent.com/u/7063592?v=3","gravatar_id":"","url":"https://api.github.com/users/vishh","html_url":"https://github.com/vishh","followers_url":"https://api.github.com/users/vishh/followers","following_url":"https://api.github.com/users/vishh/following{/other_user}","gists_url":"https://api.github.com/users/vishh/gists{/gist_id}","starred_url":"https://api.github.com/users/vishh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vishh/subscriptions","organizations_url":"https://api.github.com/users/vishh/orgs","repos_url":"https://api.github.com/users/vishh/repos","events_url":"https://api.github.com/users/vishh/events{/privacy}","received_events_url":"https://api.github.com/users/vishh/received_events","type":"User","site_admin":false},"body":"You don't have to include this logic here. It is used by some users to account for externally mounted volumes.","created_at":"2016-03-23T18:45:07Z","updated_at":"2016-03-23T18:45:07Z","html_url":"https://github.com/google/cadvisor/pull/1154#discussion_r57215239","pull_request_url":"https://api.github.com/repos/google/cadvisor/pulls/1154","_links":{"self":{"href":"https://api.github.com/repos/google/cadvisor/pulls/comments/57215239"},"html":{"href":"https://github.com/google/cadvisor/pull/1154#discussion_r57215239"},"pull_request":{"href":"https://api.github.com/repos/google/cadvisor/pulls/1154"}}},"pull_request":{"url":"https://api.github.com/repos/google/cadvisor/pulls/1154","id":62344305,"html_url":"https://github.com/google/cadvisor/pull/1154","diff_url":"https://github.com/google/cadvisor/pull/1154.diff","patch_url":"https://github.com/google/cadvisor/pull/1154.patch","issue_url":"https://api.github.com/repos/google/cadvisor/issues/1154","number":1154,"state":"open","locked":false,"title":"Part 2 of rkt support","user":{"login":"sjpotter","id":1659735,"avatar_url":"https://avatars.githubusercontent.com/u/1659735?v=3","gravatar_id":"","url":"https://api.github.com/users/sjpotter","html_url":"https://github.com/sjpotter","followers_url":"https://api.github.com/users/sjpotter/followers","following_url":"https://api.github.com/users/sjpotter/following{/other_user}","gists_url":"https://api.github.com/users/sjpotter/gists{/gist_id}","starred_url":"https://api.github.com/users/sjpotter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjpotter/subscriptions","organizations_url":"https://api.github.com/users/sjpotter/orgs","repos_url":"https://api.github.com/users/sjpotter/repos","events_url":"https://api.github.com/users/sjpotter/events{/privacy}","received_events_url":"https://api.github.com/users/sjpotter/received_events","type":"User","site_admin":false},"body":"The actual handler\r\n\r\nSince I originally wrote it and splitting it in 2 an ignore metrics map was created.  I think I captured it, but not 100% sure.\r\n\r\nThe design of this is to capture 2 of the cgroups as a rkt pod and a rkt container pair.\r\n\r\ni.e. under the cgroup fs we'd have\r\n\r\nmachine-slice/<rkt pod>/system.slice/<rkt container>\r\n\r\nin terms of raw containers this will ignore any system.slice directory under the rkt pod and will not be tracked by cadvisor by either.  I think this is correct, but feedback would be appreciated.\r\n\r\nI'm also not convinced by the efforts of splitting the fs path, I was reccomended to do this over a regex but again feedback would be appreciated.","created_at":"2016-03-10T06:13:50Z","updated_at":"2016-03-23T18:45:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8ac68d9b0095ff3fe40e5b7c8a371a073ee6f63","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/cadvisor/pulls/1154/commits","review_comments_url":"https://api.github.com/repos/google/cadvisor/pulls/1154/comments","review_comment_url":"https://api.github.com/repos/google/cadvisor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/cadvisor/issues/1154/comments","statuses_url":"https://api.github.com/repos/google/cadvisor/statuses/4d0f8fafbe38aaca5ff05d65e61e9b4708c741df","head":{"label":"sjpotter:rkt","ref":"rkt","sha":"4d0f8fafbe38aaca5ff05d65e61e9b4708c741df","user":{"login":"sjpotter","id":1659735,"avatar_url":"https://avatars.githubusercontent.com/u/1659735?v=3","gravatar_id":"","url":"https://api.github.com/users/sjpotter","html_url":"https://github.com/sjpotter","followers_url":"https://api.github.com/users/sjpotter/followers","following_url":"https://api.github.com/users/sjpotter/following{/other_user}","gists_url":"https://api.github.com/users/sjpotter/gists{/gist_id}","starred_url":"https://api.github.com/users/sjpotter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjpotter/subscriptions","organizations_url":"https://api.github.com/users/sjpotter/orgs","repos_url":"https://api.github.com/users/sjpotter/repos","events_url":"https://api.github.com/users/sjpotter/events{/privacy}","received_events_url":"https://api.github.com/users/sjpotter/received_events","type":"User","site_admin":false},"repo":{"id":49527299,"name":"cadvisor","full_name":"sjpotter/cadvisor","owner":{"login":"sjpotter","id":1659735,"avatar_url":"https://avatars.githubusercontent.com/u/1659735?v=3","gravatar_id":"","url":"https://api.github.com/users/sjpotter","html_url":"https://github.com/sjpotter","followers_url":"https://api.github.com/users/sjpotter/followers","following_url":"https://api.github.com/users/sjpotter/following{/other_user}","gists_url":"https://api.github.com/users/sjpotter/gists{/gist_id}","starred_url":"https://api.github.com/users/sjpotter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjpotter/subscriptions","organizations_url":"https://api.github.com/users/sjpotter/orgs","repos_url":"https://api.github.com/users/sjpotter/repos","events_url":"https://api.github.com/users/sjpotter/events{/privacy}","received_events_url":"https://api.github.com/users/sjpotter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sjpotter/cadvisor","description":"Analyzes resource usage and performance characteristics of running containers.","fork":true,"url":"https://api.github.com/repos/sjpotter/cadvisor","forks_url":"https://api.github.com/repos/sjpotter/cadvisor/forks","keys_url":"https://api.github.com/repos/sjpotter/cadvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sjpotter/cadvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sjpotter/cadvisor/teams","hooks_url":"https://api.github.com/repos/sjpotter/cadvisor/hooks","issue_events_url":"https://api.github.com/repos/sjpotter/cadvisor/issues/events{/number}","events_url":"https://api.github.com/repos/sjpotter/cadvisor/events","assignees_url":"https://api.github.com/repos/sjpotter/cadvisor/assignees{/user}","branches_url":"https://api.github.com/repos/sjpotter/cadvisor/branches{/branch}","tags_url":"https://api.github.com/repos/sjpotter/cadvisor/tags","blobs_url":"https://api.github.com/repos/sjpotter/cadvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sjpotter/cadvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sjpotter/cadvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/sjpotter/cadvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sjpotter/cadvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/sjpotter/cadvisor/languages","stargazers_url":"https://api.github.com/repos/sjpotter/cadvisor/stargazers","contributors_url":"https://api.github.com/repos/sjpotter/cadvisor/contributors","subscribers_url":"https://api.github.com/repos/sjpotter/cadvisor/subscribers","subscription_url":"https://api.github.com/repos/sjpotter/cadvisor/subscription","commits_url":"https://api.github.com/repos/sjpotter/cadvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/sjpotter/cadvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/sjpotter/cadvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/sjpotter/cadvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/sjpotter/cadvisor/contents/{+path}","compare_url":"https://api.github.com/repos/sjpotter/cadvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sjpotter/cadvisor/merges","archive_url":"https://api.github.com/repos/sjpotter/cadvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sjpotter/cadvisor/downloads","issues_url":"https://api.github.com/repos/sjpotter/cadvisor/issues{/number}","pulls_url":"https://api.github.com/repos/sjpotter/cadvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/sjpotter/cadvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/sjpotter/cadvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sjpotter/cadvisor/labels{/name}","releases_url":"https://api.github.com/repos/sjpotter/cadvisor/releases{/id}","deployments_url":"https://api.github.com/repos/sjpotter/cadvisor/deployments","created_at":"2016-01-12T20:35:02Z","updated_at":"2016-01-12T20:35:03Z","pushed_at":"2016-03-22T00:34:49Z","git_url":"git://github.com/sjpotter/cadvisor.git","ssh_url":"git@github.com:sjpotter/cadvisor.git","clone_url":"https://github.com/sjpotter/cadvisor.git","svn_url":"https://github.com/sjpotter/cadvisor","homepage":"","size":20009,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"google:master","ref":"master","sha":"b9e36443c490f54cee2f1539d27364730a226e33","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":20653934,"name":"cadvisor","full_name":"google/cadvisor","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/cadvisor","description":"Analyzes resource usage and performance characteristics of running containers.","fork":false,"url":"https://api.github.com/repos/google/cadvisor","forks_url":"https://api.github.com/repos/google/cadvisor/forks","keys_url":"https://api.github.com/repos/google/cadvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/cadvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/cadvisor/teams","hooks_url":"https://api.github.com/repos/google/cadvisor/hooks","issue_events_url":"https://api.github.com/repos/google/cadvisor/issues/events{/number}","events_url":"https://api.github.com/repos/google/cadvisor/events","assignees_url":"https://api.github.com/repos/google/cadvisor/assignees{/user}","branches_url":"https://api.github.com/repos/google/cadvisor/branches{/branch}","tags_url":"https://api.github.com/repos/google/cadvisor/tags","blobs_url":"https://api.github.com/repos/google/cadvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/cadvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/cadvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/cadvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/cadvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/google/cadvisor/languages","stargazers_url":"https://api.github.com/repos/google/cadvisor/stargazers","contributors_url":"https://api.github.com/repos/google/cadvisor/contributors","subscribers_url":"https://api.github.com/repos/google/cadvisor/subscribers","subscription_url":"https://api.github.com/repos/google/cadvisor/subscription","commits_url":"https://api.github.com/repos/google/cadvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/cadvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/cadvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/cadvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/cadvisor/contents/{+path}","compare_url":"https://api.github.com/repos/google/cadvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/cadvisor/merges","archive_url":"https://api.github.com/repos/google/cadvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/cadvisor/downloads","issues_url":"https://api.github.com/repos/google/cadvisor/issues{/number}","pulls_url":"https://api.github.com/repos/google/cadvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/google/cadvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/google/cadvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/cadvisor/labels{/name}","releases_url":"https://api.github.com/repos/google/cadvisor/releases{/id}","deployments_url":"https://api.github.com/repos/google/cadvisor/deployments","created_at":"2014-06-09T16:36:33Z","updated_at":"2016-03-22T19:34:51Z","pushed_at":"2016-03-23T16:14:46Z","git_url":"git://github.com/google/cadvisor.git","ssh_url":"git@github.com:google/cadvisor.git","clone_url":"https://github.com/google/cadvisor.git","svn_url":"https://github.com/google/cadvisor","homepage":"","size":24553,"stargazers_count":3692,"watchers_count":3692,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":498,"mirror_url":null,"open_issues_count":136,"forks":498,"open_issues":136,"watchers":3692,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/cadvisor/pulls/1154"},"html":{"href":"https://github.com/google/cadvisor/pull/1154"},"issue":{"href":"https://api.github.com/repos/google/cadvisor/issues/1154"},"comments":{"href":"https://api.github.com/repos/google/cadvisor/issues/1154/comments"},"review_comments":{"href":"https://api.github.com/repos/google/cadvisor/pulls/1154/comments"},"review_comment":{"href":"https://api.github.com/repos/google/cadvisor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/cadvisor/pulls/1154/commits"},"statuses":{"href":"https://api.github.com/repos/google/cadvisor/statuses/4d0f8fafbe38aaca5ff05d65e61e9b4708c741df"}}}}