Merge "Manage temp dirs from git clone."
This commit is contained in:
commit
3655659bb7
|
@ -107,6 +107,7 @@ class Armada(object):
|
||||||
self.k8s_wait_attempt_sleep = k8s_wait_attempt_sleep
|
self.k8s_wait_attempt_sleep = k8s_wait_attempt_sleep
|
||||||
self.manifest = Manifest(
|
self.manifest = Manifest(
|
||||||
self.documents, target_manifest=target_manifest).get_manifest()
|
self.documents, target_manifest=target_manifest).get_manifest()
|
||||||
|
self.cloned_dirs = set()
|
||||||
|
|
||||||
def find_release_chart(self, known_releases, release_name):
|
def find_release_chart(self, known_releases, release_name):
|
||||||
'''
|
'''
|
||||||
|
@ -194,8 +195,9 @@ class Armada(object):
|
||||||
*repo_branch,
|
*repo_branch,
|
||||||
proxy_server=proxy_server,
|
proxy_server=proxy_server,
|
||||||
auth_method=auth_method)
|
auth_method=auth_method)
|
||||||
repos[repo_branch] = repo_dir
|
self.cloned_dirs.add(repo_dir)
|
||||||
|
|
||||||
|
repos[repo_branch] = repo_dir
|
||||||
chart['source_dir'] = (repo_dir, subpath)
|
chart['source_dir'] = (repo_dir, subpath)
|
||||||
else:
|
else:
|
||||||
chart['source_dir'] = (repos.get(repo_branch), subpath)
|
chart['source_dir'] = (repos.get(repo_branch), subpath)
|
||||||
|
@ -523,14 +525,9 @@ class Armada(object):
|
||||||
LOG.info("Performing post-flight operations.")
|
LOG.info("Performing post-flight operations.")
|
||||||
|
|
||||||
# Delete temp dirs used for deployment
|
# Delete temp dirs used for deployment
|
||||||
for group in self.manifest.get(const.KEYWORD_ARMADA, {}).get(
|
for cloned_dir in self.cloned_dirs:
|
||||||
const.KEYWORD_GROUPS, []):
|
LOG.debug('Removing cloned temp directory: %s', cloned_dir)
|
||||||
for ch in group.get(const.KEYWORD_CHARTS, []):
|
source.source_cleanup(cloned_dir)
|
||||||
chart = ch.get('chart', {})
|
|
||||||
if chart.get('source', {}).get('type') == 'git':
|
|
||||||
source_dir = chart.get('source_dir')
|
|
||||||
if isinstance(source_dir, tuple) and source_dir:
|
|
||||||
source.source_cleanup(source_dir[0])
|
|
||||||
|
|
||||||
def _wait_until_ready(self, release_name, wait_labels, namespace, timeout):
|
def _wait_until_ready(self, release_name, wait_labels, namespace, timeout):
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
|
|
|
@ -52,7 +52,7 @@ class GitTestCase(base.ArmadaTestCase):
|
||||||
url = 'https://github.com/openstack/airship-armada'
|
url = 'https://github.com/openstack/airship-armada'
|
||||||
commit = 'cba78d1d03e4910f6ab1691bae633c5bddce893d'
|
commit = 'cba78d1d03e4910f6ab1691bae633c5bddce893d'
|
||||||
git_dir = source.git_clone(url, commit)
|
git_dir = source.git_clone(url, commit)
|
||||||
self._validate_git_clone(git_dir)
|
self._validate_git_clone(git_dir, commit)
|
||||||
|
|
||||||
@testtools.skipUnless(base.is_connected(),
|
@testtools.skipUnless(base.is_connected(),
|
||||||
'git clone requires network connectivity.')
|
'git clone requires network connectivity.')
|
||||||
|
|
|
@ -57,7 +57,6 @@ def git_clone(repo_url, ref='master', proxy_server=None, auth_method=None):
|
||||||
raise source_exceptions.GitException(repo_url)
|
raise source_exceptions.GitException(repo_url)
|
||||||
|
|
||||||
env_vars = {'GIT_TERMINAL_PROMPT': '0'}
|
env_vars = {'GIT_TERMINAL_PROMPT': '0'}
|
||||||
temp_dir = tempfile.mkdtemp(prefix='armada')
|
|
||||||
ssh_cmd = None
|
ssh_cmd = None
|
||||||
|
|
||||||
if auth_method and auth_method.lower() == 'ssh':
|
if auth_method and auth_method.lower() == 'ssh':
|
||||||
|
@ -79,6 +78,8 @@ def git_clone(repo_url, ref='master', proxy_server=None, auth_method=None):
|
||||||
'with no authentication.', repo_url, ref)
|
'with no authentication.', repo_url, ref)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
temp_dir = tempfile.mkdtemp(prefix='armada')
|
||||||
|
|
||||||
if proxy_server:
|
if proxy_server:
|
||||||
LOG.debug('Cloning [%s] with proxy [%s]', repo_url, proxy_server)
|
LOG.debug('Cloning [%s] with proxy [%s]', repo_url, proxy_server)
|
||||||
repo = Repo.clone_from(
|
repo = Repo.clone_from(
|
||||||
|
|
Loading…
Reference in New Issue