{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/82826447","pull_request_review_id":3706346,"id":82826447,"diff_hunk":"@@ -0,0 +1,114 @@\n+/*\n+Copyright 2014 The Kubernetes Authors.\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 util\n+\n+import (\n+\t\"fmt\"\n+\t\"os\"\n+\t\"os/user\"\n+\t\"strings\"\n+\n+\t\"github.com/golang/glog\"\n+\t\"github.com/renstrom/dedent\"\n+)\n+\n+const (\n+\tDefaultErrorExitCode = 1\n+\tEX_USAGE             = 64\n+\tEX_DATAERR           = 65\n+\tEX_NOINPUT           = 66\n+\tEX_NOUSER            = 67\n+\tEX_NOHOST            = 68\n+\tEX_UNAVAILABLE       = 69\n+\tEX_SOFTWARE          = 70\n+\tEX_OSERR             = 71\n+\tEX_OSFILE            = 72\n+\tEX_CANTCREAT         = 73\n+\tEX_IOERR             = 74\n+\tEX_TEMPFAIL          = 75\n+\tEX_PROTOCOL          = 76\n+\tEX_NOPERM            = 77\n+\tEX_CONFIG            = 78\n+)\n+\n+var AlphaWarningOnExit = dedent.Dedent(`\n+\tkubeadm: I am an alpha version, my authors welcome your feedback and bug reports\n+\tkubeadm: please create issue an using https://github.com/kubernetes/kubernetes/issues/new\n+\tkubeadm: and make sure to mention @kubernetes/sig-cluster-lifecycle. Thank you!\n+`)\n+\n+type NotRootError struct {","path":"cmd/kubeadm/app/util/error.go","position":39,"original_position":54,"commit_id":"cb2d6e4e15688661a9a8fbc838e38bfa06cdbfd4","original_commit_id":"90f586624e0de2822e7ffda93b5bd141b1deeeee","user":{"login":"dmmcquay","id":1700422,"avatar_url":"https://avatars.githubusercontent.com/u/1700422?v=3","gravatar_id":"","url":"https://api.github.com/users/dmmcquay","html_url":"https://github.com/dmmcquay","followers_url":"https://api.github.com/users/dmmcquay/followers","following_url":"https://api.github.com/users/dmmcquay/following{/other_user}","gists_url":"https://api.github.com/users/dmmcquay/gists{/gist_id}","starred_url":"https://api.github.com/users/dmmcquay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmmcquay/subscriptions","organizations_url":"https://api.github.com/users/dmmcquay/orgs","repos_url":"https://api.github.com/users/dmmcquay/repos","events_url":"https://api.github.com/users/dmmcquay/events{/privacy}","received_events_url":"https://api.github.com/users/dmmcquay/received_events","type":"User","site_admin":false},"body":"I looked at your open PR #34535 and I think we could move towards a consensus between the work there and some of the ideas I have in this PR. \r\n\r\nI am not suggesting that we do a struct per error approach on all errors.  There are going to be some errors that we want to handle a specific way and others that are more general. In my opinion, the only way to be able to handle diverse errors in different ways (different exit codes, etc.) is not to inspect the contents of the error (something like strings.Contains()), but be able to detect what type of error they are. Which is why structs that implement the error interface would work great in this case. (See http://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully)\r\n\r\nI personally don't like that you pass around []string, I think they easily could be a []error.  Also, in your PR, there are more than one place where errors are handled and also more than one place where you program may exit.  I think it is best practice to have one place that handles errors and determines how the program should exit (errors codes, logging messages, etc). \r\n\r\nIf we moved towards having an []error rather than []string, one could iterate over the errors and handle each accordingly.  If some only require some logging, they just log, while if others require more action, they can do so. \r\n\r\nAs for glog, I am not personally attached to it.  Although, logs that are more machine readable are helpful, something the default log packages doesn't handle great.  \r\n\r\nI think in the long run, getting this right is not so much for humans as it is for automating this process.  Meaningful exit codes allow things to be scripted and the returning errors codes have a lot of value in allowing said system to be designed. ","created_at":"2016-10-11T15:56:17Z","updated_at":"2016-10-11T15:56:17Z","html_url":"https://github.com/kubernetes/kubernetes/pull/34341#discussion_r82826447","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/82826447"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/34341#discussion_r82826447"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341","id":88475681,"html_url":"https://github.com/kubernetes/kubernetes/pull/34341","diff_url":"https://github.com/kubernetes/kubernetes/pull/34341.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/34341.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34341","number":34341,"state":"open","locked":false,"title":"kubeadm must validate superuser privileges","user":{"login":"dmmcquay","id":1700422,"avatar_url":"https://avatars.githubusercontent.com/u/1700422?v=3","gravatar_id":"","url":"https://api.github.com/users/dmmcquay","html_url":"https://github.com/dmmcquay","followers_url":"https://api.github.com/users/dmmcquay/followers","following_url":"https://api.github.com/users/dmmcquay/following{/other_user}","gists_url":"https://api.github.com/users/dmmcquay/gists{/gist_id}","starred_url":"https://api.github.com/users/dmmcquay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmmcquay/subscriptions","organizations_url":"https://api.github.com/users/dmmcquay/orgs","repos_url":"https://api.github.com/users/dmmcquay/repos","events_url":"https://api.github.com/users/dmmcquay/events{/privacy}","received_events_url":"https://api.github.com/users/dmmcquay/received_events","type":"User","site_admin":false},"body":"Checks that user running kubeamd init and join is root and will only execute\r\ncommand if user is root. Moved away from using kubectl error handling to\r\nhaving kubeadm handle its own errors. This should allow kubeadm to have\r\nmore meaningful errors, exit codes, and logging for specific kubeadm use\r\ncases.\r\n\r\nfixes #33908\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.kubernetes.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/34341)\n<!-- Reviewable:end -->\n","created_at":"2016-10-07T17:17:27Z","updated_at":"2016-10-11T15:56:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"582b0a339c1b7838e53f13bc025deeedd9fbb991","assignee":{"login":"errordeveloper","id":251467,"avatar_url":"https://avatars.githubusercontent.com/u/251467?v=3","gravatar_id":"","url":"https://api.github.com/users/errordeveloper","html_url":"https://github.com/errordeveloper","followers_url":"https://api.github.com/users/errordeveloper/followers","following_url":"https://api.github.com/users/errordeveloper/following{/other_user}","gists_url":"https://api.github.com/users/errordeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/errordeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/errordeveloper/subscriptions","organizations_url":"https://api.github.com/users/errordeveloper/orgs","repos_url":"https://api.github.com/users/errordeveloper/repos","events_url":"https://api.github.com/users/errordeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/errordeveloper/received_events","type":"User","site_admin":false},"assignees":[{"login":"errordeveloper","id":251467,"avatar_url":"https://avatars.githubusercontent.com/u/251467?v=3","gravatar_id":"","url":"https://api.github.com/users/errordeveloper","html_url":"https://github.com/errordeveloper","followers_url":"https://api.github.com/users/errordeveloper/followers","following_url":"https://api.github.com/users/errordeveloper/following{/other_user}","gists_url":"https://api.github.com/users/errordeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/errordeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/errordeveloper/subscriptions","organizations_url":"https://api.github.com/users/errordeveloper/orgs","repos_url":"https://api.github.com/users/errordeveloper/repos","events_url":"https://api.github.com/users/errordeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/errordeveloper/received_events","type":"User","site_admin":false},{"login":"luxas","id":5442475,"avatar_url":"https://avatars.githubusercontent.com/u/5442475?v=3","gravatar_id":"","url":"https://api.github.com/users/luxas","html_url":"https://github.com/luxas","followers_url":"https://api.github.com/users/luxas/followers","following_url":"https://api.github.com/users/luxas/following{/other_user}","gists_url":"https://api.github.com/users/luxas/gists{/gist_id}","starred_url":"https://api.github.com/users/luxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luxas/subscriptions","organizations_url":"https://api.github.com/users/luxas/orgs","repos_url":"https://api.github.com/users/luxas/repos","events_url":"https://api.github.com/users/luxas/events{/privacy}","received_events_url":"https://api.github.com/users/luxas/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34341/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/cb2d6e4e15688661a9a8fbc838e38bfa06cdbfd4","head":{"label":"apprenda:kubeadm-require-root","ref":"kubeadm-require-root","sha":"cb2d6e4e15688661a9a8fbc838e38bfa06cdbfd4","user":{"login":"apprenda","id":6901411,"avatar_url":"https://avatars.githubusercontent.com/u/6901411?v=3","gravatar_id":"","url":"https://api.github.com/users/apprenda","html_url":"https://github.com/apprenda","followers_url":"https://api.github.com/users/apprenda/followers","following_url":"https://api.github.com/users/apprenda/following{/other_user}","gists_url":"https://api.github.com/users/apprenda/gists{/gist_id}","starred_url":"https://api.github.com/users/apprenda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apprenda/subscriptions","organizations_url":"https://api.github.com/users/apprenda/orgs","repos_url":"https://api.github.com/users/apprenda/repos","events_url":"https://api.github.com/users/apprenda/events{/privacy}","received_events_url":"https://api.github.com/users/apprenda/received_events","type":"Organization","site_admin":false},"repo":{"id":57914139,"name":"kubernetes","full_name":"apprenda/kubernetes","owner":{"login":"apprenda","id":6901411,"avatar_url":"https://avatars.githubusercontent.com/u/6901411?v=3","gravatar_id":"","url":"https://api.github.com/users/apprenda","html_url":"https://github.com/apprenda","followers_url":"https://api.github.com/users/apprenda/followers","following_url":"https://api.github.com/users/apprenda/following{/other_user}","gists_url":"https://api.github.com/users/apprenda/gists{/gist_id}","starred_url":"https://api.github.com/users/apprenda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apprenda/subscriptions","organizations_url":"https://api.github.com/users/apprenda/orgs","repos_url":"https://api.github.com/users/apprenda/repos","events_url":"https://api.github.com/users/apprenda/events{/privacy}","received_events_url":"https://api.github.com/users/apprenda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apprenda/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/apprenda/kubernetes","forks_url":"https://api.github.com/repos/apprenda/kubernetes/forks","keys_url":"https://api.github.com/repos/apprenda/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apprenda/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apprenda/kubernetes/teams","hooks_url":"https://api.github.com/repos/apprenda/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/apprenda/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/apprenda/kubernetes/events","assignees_url":"https://api.github.com/repos/apprenda/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/apprenda/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/apprenda/kubernetes/tags","blobs_url":"https://api.github.com/repos/apprenda/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apprenda/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apprenda/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/apprenda/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apprenda/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/apprenda/kubernetes/languages","stargazers_url":"https://api.github.com/repos/apprenda/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/apprenda/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/apprenda/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/apprenda/kubernetes/subscription","commits_url":"https://api.github.com/repos/apprenda/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/apprenda/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/apprenda/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/apprenda/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/apprenda/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/apprenda/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apprenda/kubernetes/merges","archive_url":"https://api.github.com/repos/apprenda/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apprenda/kubernetes/downloads","issues_url":"https://api.github.com/repos/apprenda/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/apprenda/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/apprenda/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/apprenda/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apprenda/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/apprenda/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/apprenda/kubernetes/deployments","created_at":"2016-05-02T19:07:17Z","updated_at":"2016-05-02T19:07:32Z","pushed_at":"2016-10-11T13:21:16Z","git_url":"git://github.com/apprenda/kubernetes.git","ssh_url":"git@github.com:apprenda/kubernetes.git","clone_url":"https://github.com/apprenda/kubernetes.git","svn_url":"https://github.com/apprenda/kubernetes","homepage":"http://kubernetes.io","size":346023,"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":"kubernetes:master","ref":"master","sha":"3c9600e4c45d2f19fa41c0864136a3ea8a37c70a","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Production-Grade Container Scheduling and Management","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/kubernetes/deployments","created_at":"2014-06-06T22:56:04Z","updated_at":"2016-10-11T14:38:36Z","pushed_at":"2016-10-11T15:54:06Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":584730,"stargazers_count":17457,"watchers_count":17457,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5669,"mirror_url":null,"open_issues_count":4928,"forks":5669,"open_issues":4928,"watchers":17457,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/34341"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/34341"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/34341/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34341/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/cb2d6e4e15688661a9a8fbc838e38bfa06cdbfd4"}}}}
{"actor":{"display_login":"dmmcquay"}}