{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/184430130","pull_request_review_id":115622880,"id":184430130,"diff_hunk":"@@ -0,0 +1,176 @@\n+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-\n+#\n+# Copyright 2018 Canonical Ltd\n+#\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License version 3 as\n+# published by the Free Software Foundation.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+\n+import logging\n+from typing import List  # noqa\n+\n+from snapcraft.internal.errors import SnapcraftError\n+\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+class ContainerError(SnapcraftError):\n+    \"\"\"Base class for all container-related exceptions.\n+\n+    :cvar fmt: A format string that daughter classes override\n+\n+    \"\"\"\n+\n+\n+class ContainerArchitectureError(ContainerError):\n+\n+    fmt = (\n+        \"Failed to detect container architecture: \"\n+        \"The output from 'lxc info' could not be read:\\n{lxc_info}\"\n+    )\n+\n+    def __init__(self, lxc_info: str) -> None:\n+        super().__init__(lxc_info=lxc_info)\n+\n+\n+class ContainerLXDNotInstalledError(ContainerError):\n+\n+    fmt = (\n+        \"Failed to initialize container: \"\n+        \"LXD could not be found. \"\n+        \"You must have LXD installed in order to use cleanbuild.\\n\"\n+        \"Refer to the documentation at \"\n+        \"https://linuxcontainers.org/lxd/getting-started-cli.\"\n+    )\n+\n+    def __init__(self):\n+        super().__init__()\n+\n+\n+class ContainerLXDRemoteNotFoundError(ContainerError):\n+\n+    fmt = (\n+        \"Failed to initialize container: \"\n+        \"There are either no permissions or the remote {remote!r} \"\n+        \"does not exist. \"\n+        \"Verify the existing remotes by running `lxc remote list`.\\n\"\n+        \"Refer to the documentation at \"\n+        \"https://linuxcontainers.org/lxd/getting-started-cli.\"\n+    )\n+\n+    def __init__(self, remote):\n+        super().__init__(remote=remote)\n+\n+\n+class ContainerLXDSetupError(ContainerError):\n+\n+    fmt = (\n+        \"Failed to initialize container: \"\n+        \"Something seems to be wrong with your installation of LXD.\\n\"\n+        \"Refer to the documentation at \"\n+        \"https://linuxcontainers.org/lxd/getting-started-cli.\"\n+    )\n+\n+    def __init__(self):\n+        super().__init__()\n+\n+\n+class ContainerStartFailedError(ContainerError):\n+\n+    fmt = (\n+        \"Failed to start container: \"\n+        \"The local folder could not be mounted into the container. \"","path":"snapcraft/internal/lxd/_errors.py","position":91,"original_position":91,"commit_id":"ff89e9151bc6b6f701c056716717ea9693d28c49","original_commit_id":"ff89e9151bc6b6f701c056716717ea9693d28c49","user":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars0.githubusercontent.com/u/946674?v=4","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"body":"Newline after this line.","created_at":"2018-04-26T15:23:44Z","updated_at":"2018-04-26T15:39:26Z","html_url":"https://github.com/snapcore/snapcraft/pull/2095#discussion_r184430130","pull_request_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/184430130"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/2095#discussion_r184430130"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095","id":183367872,"html_url":"https://github.com/snapcore/snapcraft/pull/2095","diff_url":"https://github.com/snapcore/snapcraft/pull/2095.diff","patch_url":"https://github.com/snapcore/snapcraft/pull/2095.patch","issue_url":"https://api.github.com/repos/snapcore/snapcraft/issues/2095","number":2095,"state":"open","locked":false,"title":"lxd: proper error classes for container errors","user":{"login":"kalikiana","id":1204189,"avatar_url":"https://avatars0.githubusercontent.com/u/1204189?v=4","gravatar_id":"","url":"https://api.github.com/users/kalikiana","html_url":"https://github.com/kalikiana","followers_url":"https://api.github.com/users/kalikiana/followers","following_url":"https://api.github.com/users/kalikiana/following{/other_user}","gists_url":"https://api.github.com/users/kalikiana/gists{/gist_id}","starred_url":"https://api.github.com/users/kalikiana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalikiana/subscriptions","organizations_url":"https://api.github.com/users/kalikiana/orgs","repos_url":"https://api.github.com/users/kalikiana/repos","events_url":"https://api.github.com/users/kalikiana/events{/privacy}","received_events_url":"https://api.github.com/users/kalikiana/received_events","type":"User","site_admin":false},"body":"- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?\r\n- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?\r\n- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?\r\n- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?\r\n- [x] Have you successfully run `./runtests.sh static`?\r\n- [x] Have you successfully run `./runtests.sh unit`?\r\n\r\n-----\r\nThis PR refactors container errors to have proper classes and moves them into the LXD module. Also errors are moved into a separate unit test. This includes a fix for error handling of and tests for getting the architecture from the container.\r\n\r\nThis is part of #1705.\r\nFixes: [LP: #1734233](https://bugs.launchpad.net/snapcraft/+bug/1734233) [LP: #1734235](https://bugs.launchpad.net/snapcraft/+bug/1734235)\r\n\r\nThe following new tests are affected:\r\n\r\n - tests.unit.test_lxd_errors\r\n - To verify the new and updated error classes.\r\n - tests.unit.lxd.test_architecture_*\r\n - To verify failing to get the architecture from the LXD container.\r\n\r\nI locally ran the tests:\r\n - `./runtests.sh tests/unit` with unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576), `tests.unit.test_mangling.TestClearExecstack.test_execstack_clears` and `tests.unit.test_elf`.\r\n - `./runtests.sh tests/integration` with one unrelated failure in [tests.integration.general.test_parser.TestParserWikis](https://bugs.launchpad.net/snapcraft/+bug/1752580)\r\n - `./runtests.sh static`: Everything passed","created_at":"2018-04-23T09:03:08Z","updated_at":"2018-04-26T15:39:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd7dc577cd3b265c7d0dd9cf0bd12a333774e478","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/issues/2095/comments","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/ff89e9151bc6b6f701c056716717ea9693d28c49","head":{"label":"kalikiana:lxd-errors","ref":"lxd-errors","sha":"ff89e9151bc6b6f701c056716717ea9693d28c49","user":{"login":"kalikiana","id":1204189,"avatar_url":"https://avatars0.githubusercontent.com/u/1204189?v=4","gravatar_id":"","url":"https://api.github.com/users/kalikiana","html_url":"https://github.com/kalikiana","followers_url":"https://api.github.com/users/kalikiana/followers","following_url":"https://api.github.com/users/kalikiana/following{/other_user}","gists_url":"https://api.github.com/users/kalikiana/gists{/gist_id}","starred_url":"https://api.github.com/users/kalikiana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalikiana/subscriptions","organizations_url":"https://api.github.com/users/kalikiana/orgs","repos_url":"https://api.github.com/users/kalikiana/repos","events_url":"https://api.github.com/users/kalikiana/events{/privacy}","received_events_url":"https://api.github.com/users/kalikiana/received_events","type":"User","site_admin":false},"repo":{"id":73799360,"name":"snapcraft","full_name":"kalikiana/snapcraft","owner":{"login":"kalikiana","id":1204189,"avatar_url":"https://avatars0.githubusercontent.com/u/1204189?v=4","gravatar_id":"","url":"https://api.github.com/users/kalikiana","html_url":"https://github.com/kalikiana","followers_url":"https://api.github.com/users/kalikiana/followers","following_url":"https://api.github.com/users/kalikiana/following{/other_user}","gists_url":"https://api.github.com/users/kalikiana/gists{/gist_id}","starred_url":"https://api.github.com/users/kalikiana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalikiana/subscriptions","organizations_url":"https://api.github.com/users/kalikiana/orgs","repos_url":"https://api.github.com/users/kalikiana/repos","events_url":"https://api.github.com/users/kalikiana/events{/privacy}","received_events_url":"https://api.github.com/users/kalikiana/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kalikiana/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":true,"url":"https://api.github.com/repos/kalikiana/snapcraft","forks_url":"https://api.github.com/repos/kalikiana/snapcraft/forks","keys_url":"https://api.github.com/repos/kalikiana/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kalikiana/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kalikiana/snapcraft/teams","hooks_url":"https://api.github.com/repos/kalikiana/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/kalikiana/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/kalikiana/snapcraft/events","assignees_url":"https://api.github.com/repos/kalikiana/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/kalikiana/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/kalikiana/snapcraft/tags","blobs_url":"https://api.github.com/repos/kalikiana/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kalikiana/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kalikiana/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/kalikiana/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kalikiana/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/kalikiana/snapcraft/languages","stargazers_url":"https://api.github.com/repos/kalikiana/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/kalikiana/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/kalikiana/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/kalikiana/snapcraft/subscription","commits_url":"https://api.github.com/repos/kalikiana/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/kalikiana/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/kalikiana/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/kalikiana/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/kalikiana/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/kalikiana/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kalikiana/snapcraft/merges","archive_url":"https://api.github.com/repos/kalikiana/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kalikiana/snapcraft/downloads","issues_url":"https://api.github.com/repos/kalikiana/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/kalikiana/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/kalikiana/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/kalikiana/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kalikiana/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/kalikiana/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/kalikiana/snapcraft/deployments","created_at":"2016-11-15T09:45:46Z","updated_at":"2018-04-18T10:57:52Z","pushed_at":"2018-04-26T12:33:00Z","git_url":"git://github.com/kalikiana/snapcraft.git","ssh_url":"git@github.com:kalikiana/snapcraft.git","clone_url":"https://github.com/kalikiana/snapcraft.git","svn_url":"https://github.com/kalikiana/snapcraft","homepage":null,"size":10279,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"c44a4ece95eb55eb339c4771cd84e39e75771dae","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":45199136,"name":"snapcraft","full_name":"snapcore/snapcraft","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snapcraft","description":"Package, distribute, and update any app for Linux and IoT.","fork":false,"url":"https://api.github.com/repos/snapcore/snapcraft","forks_url":"https://api.github.com/repos/snapcore/snapcraft/forks","keys_url":"https://api.github.com/repos/snapcore/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapcraft/teams","hooks_url":"https://api.github.com/repos/snapcore/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapcraft/events","assignees_url":"https://api.github.com/repos/snapcore/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapcraft/tags","blobs_url":"https://api.github.com/repos/snapcore/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapcraft/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapcraft/subscription","commits_url":"https://api.github.com/repos/snapcore/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapcraft/merges","archive_url":"https://api.github.com/repos/snapcore/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapcraft/downloads","issues_url":"https://api.github.com/repos/snapcore/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapcraft/deployments","created_at":"2015-10-29T17:23:15Z","updated_at":"2018-04-26T12:19:43Z","pushed_at":"2018-04-26T10:48:31Z","git_url":"git://github.com/snapcore/snapcraft.git","ssh_url":"git@github.com:snapcore/snapcraft.git","clone_url":"https://github.com/snapcore/snapcraft.git","svn_url":"https://github.com/snapcore/snapcraft","homepage":"","size":9543,"stargazers_count":579,"watchers_count":579,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":247,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":247,"open_issues":57,"watchers":579,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/2095"},"issue":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/2095"},"comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/2095/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2095/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapcraft/statuses/ff89e9151bc6b6f701c056716717ea9693d28c49"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"kyrofa"}}