Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around git-python resource leaks #49474

Merged
merged 2 commits into from Sep 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions tests/unit/fileserver/test_gitfs.py
Expand Up @@ -31,6 +31,7 @@
import salt.utils.platform
import salt.utils.win_functions
import salt.utils.yaml
import salt.ext.six

import salt.utils.gitfs
from salt.utils.gitfs import (
Expand Down Expand Up @@ -144,6 +145,9 @@ def tearDownClass(cls):
try:
shutil.rmtree(path, onerror=_rmtree_error)
except OSError as exc:
if exc.errno == errno.EACCES:
log.error("Access error removeing file %s", path)
continue
if exc.errno != errno.EEXIST:
raise

Expand Down Expand Up @@ -391,7 +395,9 @@ def setUpClass(cls):
try:
shutil.rmtree(TMP_REPO_DIR)
except OSError as exc:
if exc.errno != errno.ENOENT:
if exc.errno == errno.EACCES:
log.error("Access error removeing file %s", TMP_REPO_DIR)
elif exc.errno != errno.ENOENT:
raise
shutil.copytree(INTEGRATION_BASE_FILES, TMP_REPO_DIR + '/')

Expand Down Expand Up @@ -443,7 +449,9 @@ def tearDownClass(cls):
try:
salt.utils.files.rm_rf(path)
except OSError as exc:
if exc.errno != errno.EEXIST:
if exc.errno == errno.EACCES:
log.error("Access error removeing file %s", path)
elif exc.errno != errno.EEXIST:
raise

def setUp(self):
Expand All @@ -464,8 +472,14 @@ def setUp(self):
try:
salt.utils.files.rm_rf(os.path.join(self.tmp_cachedir, subdir))
except OSError as exc:
if exc.errno == errno.EACCES:
log.warning("Access error removeing file %s", os.path.join(self.tmp_cachedir, subdir))
continue
if exc.errno != errno.ENOENT:
raise
if salt.ext.six.PY3 and salt.utils.platform.is_windows():
self.setUpClass()
self.setup_loader_modules()


@skipIf(not HAS_GITPYTHON, 'GitPython >= {0} required'.format(GITPYTHON_MINVER))
Expand Down