Fix cached repositories were not passing user/token when pulling, agent.vcs_cache.clone_on_pull_fail now defaults to false

This commit is contained in:
allegroai 2024-04-19 23:50:17 +03:00
parent 41fc4ec646
commit 47147e3237
2 changed files with 6 additions and 2 deletions

View File

@ -322,6 +322,8 @@ class VCS(object):
return return
# rewrite ssh URLs only if either ssh port or ssh user are forced in config # rewrite ssh URLs only if either ssh port or ssh user are forced in config
# TODO: fix, when url is in the form of `git@domain.com:user/project.git` we will fail to get scheme
# need to add ssh:// and replace first ":" with / , unless port is specified
if parsed_url.scheme == "ssh" and ( if parsed_url.scheme == "ssh" and (
self.session.config.get('agent.force_git_ssh_port', None) or self.session.config.get('agent.force_git_ssh_port', None) or
self.session.config.get('agent.force_git_ssh_user', None) self.session.config.get('agent.force_git_ssh_user', None)
@ -595,6 +597,7 @@ class Git(VCS):
) )
def pull(self): def pull(self):
self._set_ssh_url()
self.call("fetch", "--all", "--recurse-submodules", cwd=self.location) self.call("fetch", "--all", "--recurse-submodules", cwd=self.location)
def _git_pass_auth_wrapper(self, func, *args, **kwargs): def _git_pass_auth_wrapper(self, func, *args, **kwargs):
@ -781,9 +784,10 @@ def clone_repository_cached(session, execution, destination):
try: try:
vcs.pull() vcs.pull()
except Exception as ex: except Exception as ex:
print("git pull failed: {}".format(ex))
if ( if (
session.config.get("agent.vcs_cache.enabled", False) and session.config.get("agent.vcs_cache.enabled", False) and
session.config.get("agent.vcs_cache.clone_on_pull_fail", True) session.config.get("agent.vcs_cache.clone_on_pull_fail", False)
): ):
print("pulling git failed, re-cloning: {}".format(no_password_url)) print("pulling git failed, re-cloning: {}".format(no_password_url))
rm_tree(cached_repo_path) rm_tree(cached_repo_path)

View File

@ -163,7 +163,7 @@ agent {
path: ~/.clearml/vcs-cache path: ~/.clearml/vcs-cache
# if git pull failed, always revert to re-cloning the repo, it protects against old user name changes # if git pull failed, always revert to re-cloning the repo, it protects against old user name changes
# clone_on_pull_fail: true # clone_on_pull_fail: false
}, },
# DEPRECATED: please use `venvs_cache` and set `venvs_cache.path` # DEPRECATED: please use `venvs_cache` and set `venvs_cache.path`