From e4b6179b4671b8e5c07ee4ff17894881a1e0a055 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 14 2015 06:12:15 +0000 Subject: [PATCH 1/5] Specify the TMP_FOLDER configuration key in the sample configuration file --- diff --git a/files/pagure.cfg.sample b/files/pagure.cfg.sample index 2c8fcac..0488480 100644 --- a/files/pagure.cfg.sample +++ b/files/pagure.cfg.sample @@ -109,6 +109,10 @@ BLACKLISTED_PROJECTS = ['static', 'pv'] ### the IP filter IP_ALLOWED_INTERNAL = ['127.0.0.1', 'localhost', '::1'] +### Temp folder to be used to make the clones to work around bug in libgit2: +## refs: https://github.com/libgit2/libgit2/issues/2965 +## and https://github.com/libgit2/libgit2/issues/2797 +TMP_FOLDER = '/tmp' # Authentication related configuration option From 5d28a1353c3e67b4b98a74a0c7199b4b38791eb2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 14 2015 06:12:15 +0000 Subject: [PATCH 2/5] Move the temp directory to a defined place (if the configuration has one) This is to work around a bug in libgit2: symptoms: https://github.com/libgit2/libgit2/issues/2965 cause: https://github.com/libgit2/libgit2/issues/2797 --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 5e72af5..fb614de 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -133,6 +133,8 @@ def update_git(obj, repo, repofolder, objtype='ticket'): repopath = os.path.join(repofolder, repo.path) # Clone the repo into a temp folder + tempfile.tempdir = pagure.APP.config.get( + 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) @@ -212,6 +214,8 @@ def clean_git(obj, repo, repofolder, objtype='ticket'): repopath = os.path.join(repofolder, repo.path) # Clone the repo into a temp folder + tempfile.tempdir = pagure.APP.config.get( + 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) @@ -569,6 +573,8 @@ def add_file_to_git(repo, issue, ticketfolder, user, filename, filestream): repopath = os.path.join(ticketfolder, repo.path) # Clone the repo into a temp folder + tempfile.tempdir = pagure.APP.config.get( + 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) From a650b4a4265af658ec596894716d06299ed1f0b5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 14 2015 06:13:55 +0000 Subject: [PATCH 3/5] Relocate the clone to the new temp folder also when checking if a PR can be merged --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 8101d03..d427a84 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -178,6 +178,8 @@ def mergeable_request_pull(): parentpath = pagure.get_repo_path(request.project) # Clone the original repo into a temp folder + tempfile.tempdir = pagure.APP.config.get( + 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-pr-check') new_repo = pygit2.clone_repository(parentpath, newpath) From 8d645f89b9341bb5f087f76de5b5800654580acc Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 18 2015 12:06:13 +0000 Subject: [PATCH 4/5] Remove changes to set the tempdir of the tempfile module --- diff --git a/files/pagure.cfg.sample b/files/pagure.cfg.sample index 0488480..2c8fcac 100644 --- a/files/pagure.cfg.sample +++ b/files/pagure.cfg.sample @@ -109,10 +109,6 @@ BLACKLISTED_PROJECTS = ['static', 'pv'] ### the IP filter IP_ALLOWED_INTERNAL = ['127.0.0.1', 'localhost', '::1'] -### Temp folder to be used to make the clones to work around bug in libgit2: -## refs: https://github.com/libgit2/libgit2/issues/2965 -## and https://github.com/libgit2/libgit2/issues/2797 -TMP_FOLDER = '/tmp' # Authentication related configuration option diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index d427a84..8101d03 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -178,8 +178,6 @@ def mergeable_request_pull(): parentpath = pagure.get_repo_path(request.project) # Clone the original repo into a temp folder - tempfile.tempdir = pagure.APP.config.get( - 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-pr-check') new_repo = pygit2.clone_repository(parentpath, newpath) diff --git a/pagure/lib/git.py b/pagure/lib/git.py index fb614de..5e72af5 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -133,8 +133,6 @@ def update_git(obj, repo, repofolder, objtype='ticket'): repopath = os.path.join(repofolder, repo.path) # Clone the repo into a temp folder - tempfile.tempdir = pagure.APP.config.get( - 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) @@ -214,8 +212,6 @@ def clean_git(obj, repo, repofolder, objtype='ticket'): repopath = os.path.join(repofolder, repo.path) # Clone the repo into a temp folder - tempfile.tempdir = pagure.APP.config.get( - 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) @@ -573,8 +569,6 @@ def add_file_to_git(repo, issue, ticketfolder, user, filename, filestream): repopath = os.path.join(ticketfolder, repo.path) # Clone the repo into a temp folder - tempfile.tempdir = pagure.APP.config.get( - 'TMP_FOLDER', tempfile.gettempdir()) newpath = tempfile.mkdtemp(prefix='pagure-') new_repo = pygit2.clone_repository(repopath, newpath) From 3944103f5b07edfcefab6765d91574f8834257bb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 18 2015 12:06:30 +0000 Subject: [PATCH 5/5] Provide a way to set the temp dir in the wsgi file directly This allows overriding the system's default to work around the bugs mentioned in libgit2 --- diff --git a/files/pagure.wsgi b/files/pagure.wsgi index 91bba6e..a7da5fd 100644 --- a/files/pagure.wsgi +++ b/files/pagure.wsgi @@ -11,6 +11,12 @@ ## Set the environment variable pointing to the configuration file #os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg' +## Set the environment variable if the tmp folder needs to be moved +## Might be necessary to work around bug in libgit2: +## refs: https://github.com/libgit2/libgit2/issues/2965 +## and https://github.com/libgit2/libgit2/issues/2797 +#os.environ['TEMP'] = '/var/tmp/' + ## The following is only needed if you did not install pagure ## as a python module (for example if you run it from a git clone). #import sys