Repository: stratos Updated Branches: refs/heads/stratos-4.1.x 4fad87cd9 -> 11e618c3b
Fixing STRATOS-1582: Re-initialize Git repo credentials on ArtifactUpdatedEvent Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5dbabb36 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5dbabb36 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5dbabb36 Branch: refs/heads/stratos-4.1.x Commit: 5dbabb36e45d87d0691f432321d7e42257765af2 Parents: 4fad87c Author: Akila Perera <[email protected]> Authored: Tue Oct 6 15:19:15 2015 +0530 Committer: Akila Perera <[email protected]> Committed: Tue Oct 6 15:19:15 2015 +0530 ---------------------------------------------------------------------- .../modules/artifactmgt/git/agentgithandler.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/5dbabb36/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/artifactmgt/git/agentgithandler.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/artifactmgt/git/agentgithandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/artifactmgt/git/agentgithandler.py index b7ac62f..008c8d7 100644 --- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/artifactmgt/git/agentgithandler.py +++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/artifactmgt/git/agentgithandler.py @@ -59,11 +59,12 @@ class AgentGitHandler: subsequent calls or not :rtype: tuple(bool, bool) """ - git_repo = AgentGitHandler.get_repo(repo_info.tenant_id) + git_repo = AgentGitHandler.create_git_repo(repo_info) updated = False - if git_repo is not None: + if AgentGitHandler.get_repo(repo_info.tenant_id) is not None: # has been previously cloned, this is not the subscription run subscribe_run = False + if AgentGitHandler.is_valid_git_repository(git_repo): AgentGitHandler.log.debug("Executing git pull: [tenant-id] %s [repo-url] %s", git_repo.tenant_id, git_repo.repo_url) @@ -86,7 +87,6 @@ class AgentGitHandler: git_repo.tenant_id, git_repo.repo_url) else: # subscribing run.. need to clone - git_repo = AgentGitHandler.create_git_repo(repo_info) AgentGitHandler.log.debug("Cloning artifacts from %s for the first time to %s", git_repo.repo_url, git_repo.local_repo_path) subscribe_run = True @@ -101,7 +101,7 @@ class AgentGitHandler: # If first git clone is failed, execute retry_clone operation AgentGitHandler.log.info("Retrying Git clone operation...") AgentGitHandler.retry_clone(git_repo) - + AgentGitHandler.add_repo(git_repo) return subscribe_run, updated @staticmethod @@ -145,9 +145,6 @@ class AgentGitHandler: @staticmethod def is_valid_git_repository(git_repo): - if git_repo.cloned: - return True - output, errors = AgentGitHandler.execute_git_command(["show-ref"], git_repo.local_repo_path) if len(output) > 0: refs = output.split("\n") @@ -213,8 +210,6 @@ class AgentGitHandler: # move the cloned dir to application path copy_tree(temp_repo_path, git_repo.local_repo_path) - - AgentGitHandler.add_repo(git_repo) AgentGitHandler.log.info("Git clone operation for tenant %s successful" % git_repo.tenant_id) return git_repo except GitCommandError as e:
