{"action":"created","comment":{"url":"https://api.github.com/repos/pulp/pulp/pulls/comments/81989679","pull_request_review_id":2928497,"id":81989679,"diff_hunk":"@@ -0,0 +1,123 @@\n+import errno\n+import os\n+import shutil\n+import stat\n+\n+from celery import task\n+\n+from django.conf import settings as pulp_settings\n+\n+\n+def _working_dir_root(worker_name):\n+    \"\"\"\n+    Returns the path to the working directory of a worker\n+    :param worker_name:     Name of worker for which path is requested\n+    :type  name:            basestring\n+    :return working_directory setting from server config\n+    :rtype  str\n+    \"\"\"\n+    working_dir = pulp_settings.SERVER['working_directory']\n+    dir_root = os.path.join(working_dir, worker_name)\n+    return dir_root\n+\n+\n+def create_worker_working_directory(worker_name):\n+    \"\"\"\n+    Creates a working directory inside the working_directory as specified in /etc/pulp/server.yaml\n+    default path for working_directory is /var/cache/pulp\n+    :param worker_name:     Name of worker that uses the working directory created\n+    :type  name:            basestring\n+    :return Path to the working directory for a worker\n+    :rtype  str\n+    \"\"\"\n+    working_dir_root = _working_dir_root(worker_name)\n+    os.mkdir(working_dir_root)\n+\n+\n+def delete_worker_working_directory(worker_name):\n+    \"\"\"\n+    Deletes a working directory inside the working_directory as specified in /etc/pulp/server.yaml\n+    default path for working_directory is /var/cache/pulp\n+    :param worker_name:     Name of worker that uses the working directory being deleted\n+    :type  name:            basestring\n+    \"\"\"\n+    working_dir_root = _working_dir_root(worker_name)\n+    if os.path.exists(working_dir_root):\n+        _rmtree_fix_permissions(working_dir_root)\n+\n+\n+def _working_directory_path():\n+    \"\"\"\n+    Gets the path for a task's working directory inside a workers working directory\n+\n+    @return: full path on disk to the working directory for current task\n+    @rtype:  str\n+    \"\"\"\n+    current_task = task.current\n+    if (current_task and current_task.request and current_task.request.id and\n+            current_task.request.hostname):\n+        worker_name = current_task.request.hostname\n+        task_id = current_task.request.id\n+        worker_dir_root = _working_dir_root(worker_name)\n+        working_dir_root = os.path.join(worker_dir_root, task_id)\n+    else:\n+        return None\n+\n+    return working_dir_root\n+\n+\n+def delete_working_directory():\n+    \"\"\"\n+    Deletes working directory for a particular task.\n+\n+    @return: None\n+    @rtype:  None\n+    \"\"\"\n+    working_dir_root = _working_directory_path()\n+\n+    if working_dir_root and os.path.exists(working_dir_root):\n+        _rmtree_fix_permissions(working_dir_root)\n+\n+\n+def get_working_directory():\n+    \"\"\"\n+    Creates a working directory with task id as name. This directory resides inside a particular\n+    worker's working directory. The 'working_directory' setting in ``server`` section of\n+    /etc/pulp/server.yml defines the local path to the root of working directories. The directory\n+    is created only once per task. The path to the existing working directory is returned for all\n+    subsequent calls for that task.\n+\n+    @return: full path on disk to the working directory for current task\n+    @rtype:  str\n+    \"\"\"\n+    working_dir_root = _working_directory_path()\n+\n+    if working_dir_root:\n+        if os.path.exists(working_dir_root):\n+            return working_dir_root\n+        os.mkdir(working_dir_root)\n+        return working_dir_root\n+    else:\n+        # If path is None, this method is called outside of an asynchronous task\n+        raise RuntimeError(\"Working Directory requested outside of asynchronous task.\")\n+\n+\n+def _rmtree_fix_permissions(directory_path):","path":"tasking/pulp/tasking/storage.py","position":105,"original_position":105,"commit_id":"1e37c23d0bb9f51cfc11e5634fef89c3e27b2150","original_commit_id":"1e37c23d0bb9f51cfc11e5634fef89c3e27b2150","user":{"login":"mhrivnak","id":53091,"avatar_url":"https://avatars.githubusercontent.com/u/53091?v=3","gravatar_id":"","url":"https://api.github.com/users/mhrivnak","html_url":"https://github.com/mhrivnak","followers_url":"https://api.github.com/users/mhrivnak/followers","following_url":"https://api.github.com/users/mhrivnak/following{/other_user}","gists_url":"https://api.github.com/users/mhrivnak/gists{/gist_id}","starred_url":"https://api.github.com/users/mhrivnak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhrivnak/subscriptions","organizations_url":"https://api.github.com/users/mhrivnak/orgs","repos_url":"https://api.github.com/users/mhrivnak/repos","events_url":"https://api.github.com/users/mhrivnak/events{/privacy}","received_events_url":"https://api.github.com/users/mhrivnak/received_events","type":"User","site_admin":false},"body":"I think we should keep this behavior when removing working directories, but the comment could be improved to give better context.\r\n\r\nI believe the original problem this addressed was that when extracting the contents of a puppet module, the permissions on files could be unexpected. We've seen a surprising number of such modules. Cleanup of the working directory was not able to remove some files without first changing their permissions.\r\n\r\nThat particular plugin now makes efforts to fix those permissions so they are reasonable, but it's a best-effort. The plugin does not guarantee that all files it leaves behind will have reasonable permissions.\r\n\r\nAny other plugin that engages in extraction of files from an archive could face the same issue. Having the platform be defensive in this way is reasonable I think.","created_at":"2016-10-05T14:46:18Z","updated_at":"2016-10-05T14:46:18Z","html_url":"https://github.com/pulp/pulp/pull/2776#discussion_r81989679","pull_request_url":"https://api.github.com/repos/pulp/pulp/pulls/2776","_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments/81989679"},"html":{"href":"https://github.com/pulp/pulp/pull/2776#discussion_r81989679"},"pull_request":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2776"}}},"pull_request":{"url":"https://api.github.com/repos/pulp/pulp/pulls/2776","id":87537743,"html_url":"https://github.com/pulp/pulp/pull/2776","diff_url":"https://github.com/pulp/pulp/pull/2776.diff","patch_url":"https://github.com/pulp/pulp/pull/2776.patch","issue_url":"https://api.github.com/repos/pulp/pulp/issues/2776","number":2776,"state":"open","locked":false,"title":"Implement worker and task directory creation and cleanup","user":{"login":"BrnoPCmaniak","id":1249759,"avatar_url":"https://avatars.githubusercontent.com/u/1249759?v=3","gravatar_id":"","url":"https://api.github.com/users/BrnoPCmaniak","html_url":"https://github.com/BrnoPCmaniak","followers_url":"https://api.github.com/users/BrnoPCmaniak/followers","following_url":"https://api.github.com/users/BrnoPCmaniak/following{/other_user}","gists_url":"https://api.github.com/users/BrnoPCmaniak/gists{/gist_id}","starred_url":"https://api.github.com/users/BrnoPCmaniak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrnoPCmaniak/subscriptions","organizations_url":"https://api.github.com/users/BrnoPCmaniak/orgs","repos_url":"https://api.github.com/users/BrnoPCmaniak/repos","events_url":"https://api.github.com/users/BrnoPCmaniak/events{/privacy}","received_events_url":"https://api.github.com/users/BrnoPCmaniak/received_events","type":"User","site_admin":false},"body":"closes #2281\r\nhttps://pulp.plan.io/issues/2281\r\n\r\nThis PR have to be merged into code created by https://github.com/pulp/pulp/pull/2771","created_at":"2016-09-30T17:54:13Z","updated_at":"2016-10-05T14:46:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02eb533472553b254d6262a553518e979c647f86","assignee":{"login":"bmbouter","id":180319,"avatar_url":"https://avatars.githubusercontent.com/u/180319?v=3","gravatar_id":"","url":"https://api.github.com/users/bmbouter","html_url":"https://github.com/bmbouter","followers_url":"https://api.github.com/users/bmbouter/followers","following_url":"https://api.github.com/users/bmbouter/following{/other_user}","gists_url":"https://api.github.com/users/bmbouter/gists{/gist_id}","starred_url":"https://api.github.com/users/bmbouter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmbouter/subscriptions","organizations_url":"https://api.github.com/users/bmbouter/orgs","repos_url":"https://api.github.com/users/bmbouter/repos","events_url":"https://api.github.com/users/bmbouter/events{/privacy}","received_events_url":"https://api.github.com/users/bmbouter/received_events","type":"User","site_admin":false},"assignees":[{"login":"bmbouter","id":180319,"avatar_url":"https://avatars.githubusercontent.com/u/180319?v=3","gravatar_id":"","url":"https://api.github.com/users/bmbouter","html_url":"https://github.com/bmbouter","followers_url":"https://api.github.com/users/bmbouter/followers","following_url":"https://api.github.com/users/bmbouter/following{/other_user}","gists_url":"https://api.github.com/users/bmbouter/gists{/gist_id}","starred_url":"https://api.github.com/users/bmbouter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmbouter/subscriptions","organizations_url":"https://api.github.com/users/bmbouter/orgs","repos_url":"https://api.github.com/users/bmbouter/repos","events_url":"https://api.github.com/users/bmbouter/events{/privacy}","received_events_url":"https://api.github.com/users/bmbouter/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pulp/pulp/pulls/2776/commits","review_comments_url":"https://api.github.com/repos/pulp/pulp/pulls/2776/comments","review_comment_url":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pulp/pulp/issues/2776/comments","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/1e37c23d0bb9f51cfc11e5634fef89c3e27b2150","head":{"label":"BrnoPCmaniak:worker_storage","ref":"worker_storage","sha":"1e37c23d0bb9f51cfc11e5634fef89c3e27b2150","user":{"login":"BrnoPCmaniak","id":1249759,"avatar_url":"https://avatars.githubusercontent.com/u/1249759?v=3","gravatar_id":"","url":"https://api.github.com/users/BrnoPCmaniak","html_url":"https://github.com/BrnoPCmaniak","followers_url":"https://api.github.com/users/BrnoPCmaniak/followers","following_url":"https://api.github.com/users/BrnoPCmaniak/following{/other_user}","gists_url":"https://api.github.com/users/BrnoPCmaniak/gists{/gist_id}","starred_url":"https://api.github.com/users/BrnoPCmaniak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrnoPCmaniak/subscriptions","organizations_url":"https://api.github.com/users/BrnoPCmaniak/orgs","repos_url":"https://api.github.com/users/BrnoPCmaniak/repos","events_url":"https://api.github.com/users/BrnoPCmaniak/events{/privacy}","received_events_url":"https://api.github.com/users/BrnoPCmaniak/received_events","type":"User","site_admin":false},"repo":{"id":62882517,"name":"pulp","full_name":"BrnoPCmaniak/pulp","owner":{"login":"BrnoPCmaniak","id":1249759,"avatar_url":"https://avatars.githubusercontent.com/u/1249759?v=3","gravatar_id":"","url":"https://api.github.com/users/BrnoPCmaniak","html_url":"https://github.com/BrnoPCmaniak","followers_url":"https://api.github.com/users/BrnoPCmaniak/followers","following_url":"https://api.github.com/users/BrnoPCmaniak/following{/other_user}","gists_url":"https://api.github.com/users/BrnoPCmaniak/gists{/gist_id}","starred_url":"https://api.github.com/users/BrnoPCmaniak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrnoPCmaniak/subscriptions","organizations_url":"https://api.github.com/users/BrnoPCmaniak/orgs","repos_url":"https://api.github.com/users/BrnoPCmaniak/repos","events_url":"https://api.github.com/users/BrnoPCmaniak/events{/privacy}","received_events_url":"https://api.github.com/users/BrnoPCmaniak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BrnoPCmaniak/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":true,"url":"https://api.github.com/repos/BrnoPCmaniak/pulp","forks_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/forks","keys_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/teams","hooks_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/hooks","issue_events_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/events","assignees_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/tags","blobs_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/languages","stargazers_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/stargazers","contributors_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/contributors","subscribers_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/subscribers","subscription_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/subscription","commits_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/merges","archive_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/downloads","issues_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/labels{/name}","releases_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/releases{/id}","deployments_url":"https://api.github.com/repos/BrnoPCmaniak/pulp/deployments","created_at":"2016-07-08T11:02:40Z","updated_at":"2016-07-08T11:02:45Z","pushed_at":"2016-10-04T21:22:09Z","git_url":"git://github.com/BrnoPCmaniak/pulp.git","ssh_url":"git@github.com:BrnoPCmaniak/pulp.git","clone_url":"https://github.com/BrnoPCmaniak/pulp.git","svn_url":"https://github.com/BrnoPCmaniak/pulp","homepage":"","size":92241,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"pulp:3.0-dev","ref":"3.0-dev","sha":"1bf58ccbcac55ada30542d11c37ce09835046124","user":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"repo":{"id":5314652,"name":"pulp","full_name":"pulp/pulp","owner":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pulp/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":false,"url":"https://api.github.com/repos/pulp/pulp","forks_url":"https://api.github.com/repos/pulp/pulp/forks","keys_url":"https://api.github.com/repos/pulp/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pulp/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pulp/pulp/teams","hooks_url":"https://api.github.com/repos/pulp/pulp/hooks","issue_events_url":"https://api.github.com/repos/pulp/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/pulp/pulp/events","assignees_url":"https://api.github.com/repos/pulp/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/pulp/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/pulp/pulp/tags","blobs_url":"https://api.github.com/repos/pulp/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pulp/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pulp/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/pulp/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/pulp/pulp/languages","stargazers_url":"https://api.github.com/repos/pulp/pulp/stargazers","contributors_url":"https://api.github.com/repos/pulp/pulp/contributors","subscribers_url":"https://api.github.com/repos/pulp/pulp/subscribers","subscription_url":"https://api.github.com/repos/pulp/pulp/subscription","commits_url":"https://api.github.com/repos/pulp/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/pulp/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/pulp/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/pulp/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/pulp/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/pulp/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pulp/pulp/merges","archive_url":"https://api.github.com/repos/pulp/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pulp/pulp/downloads","issues_url":"https://api.github.com/repos/pulp/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/pulp/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/pulp/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/pulp/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pulp/pulp/labels{/name}","releases_url":"https://api.github.com/repos/pulp/pulp/releases{/id}","deployments_url":"https://api.github.com/repos/pulp/pulp/deployments","created_at":"2012-08-06T13:49:20Z","updated_at":"2016-09-28T20:39:56Z","pushed_at":"2016-10-04T22:31:09Z","git_url":"git://github.com/pulp/pulp.git","ssh_url":"git@github.com:pulp/pulp.git","clone_url":"https://github.com/pulp/pulp.git","svn_url":"https://github.com/pulp/pulp","homepage":"","size":103100,"stargazers_count":281,"watchers_count":281,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":111,"mirror_url":null,"open_issues_count":15,"forks":111,"open_issues":15,"watchers":281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2776"},"html":{"href":"https://github.com/pulp/pulp/pull/2776"},"issue":{"href":"https://api.github.com/repos/pulp/pulp/issues/2776"},"comments":{"href":"https://api.github.com/repos/pulp/pulp/issues/2776/comments"},"review_comments":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2776/comments"},"review_comment":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2776/commits"},"statuses":{"href":"https://api.github.com/repos/pulp/pulp/statuses/1e37c23d0bb9f51cfc11e5634fef89c3e27b2150"}}}}
{"actor":{"display_login":"mhrivnak"}}