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

change cache.check_migration and cache.migrate to gracefully handle if a template repository doesn't exist anymore #2769

Closed
sentry-dev-app bot opened this issue Mar 21, 2022 · 1 comment · Fixed by #2819
Assignees

Comments

@sentry-dev-app
Copy link

sentry-dev-app bot commented Mar 21, 2022

As part of check_migration/migrate we try and clone the template repository that was used to create a project, and if that repository or reference doesn't exist anymore, we raise an exception.

We should instead return that a template update is not available. And in the case of existing repo but missing reference, still try to allow updates to newer version (like if 2.3.4 tag was originally used but is now deleted, but 2.3.5 exists).

I don't think we need to inform the UI that this is the case, as we should be able to handle everything internally.

Original issue:
This happened because the branch of the template repo from which the project was initialized had been removed. We should handle such cases gracefully.

Sentry Issue: RENKU-PYTHON-4C

GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git checkout prep-0.3.1
  stderr: 'error: pathspec 'prep-0.3.1' did not match any file(s) known to git'
  File "renku/core/metadata/repository.py", line 1397, in _run_git_command
    return getattr(repository.git, command)(*args, **kwargs)
  File "git/cmd.py", line 638, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "git/cmd.py", line 1183, in _call_process
    return self.execute(call, **exec_kwargs)
  File "git/cmd.py", line 983, in execute
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)

GitCommandError: Git command failed: Cmd('git') failed due to: exit code(1)
  cmdline: git checkout prep-0.3.1
  stderr: 'error: pathspec 'prep-0.3.1' did not match any file(s) known to git'
  File "renku/core/utils/git.py", line 571, in clone_repository
    repository.checkout(checkout_revision)
  File "renku/core/metadata/repository.py", line 186, in checkout
    self.run_git_command("checkout", reference)
  File "renku/core/metadata/repository.py", line 263, in run_git_command
    return _run_git_command(self._repository, command, *args, **kwargs)
  File "renku/core/metadata/repository.py", line 1405, in _run_git_command
    ) from e

GitReferenceNotFoundError: Cannot checkout reference 'prep-0.3.1' in repository: https://github.com/swissdatasciencecenter/renku-project-template
  File "renku/core/management/template/template.py", line 427, in fetch
    repository = clone_repository(url=source, path=path, checkout_revision=reference, install_lfs=False)
  File "renku/core/utils/git.py", line 574, in clone_repository
    f"Cannot checkout reference '{checkout_revision}' in repository: {url}"

InvalidTemplateError: Cannot clone template repository from https://github.com/swissdatasciencecenter/renku-project-template
(17 additional frame(s) were not displayed)
...
  File "renku/core/commands/migrate.py", line 53, in _migrations_check
    "template_status": _template_migration_check(client),
  File "renku/core/commands/migrate.py", line 87, in _template_migration_check
    update_available, update_allowed, current_version, new_version = check_for_template_update(client)
  File "renku/core/management/template/usecase.py", line 72, in check_for_template_update
    templates_source = fetch_templates_source(source=metadata.source, reference=metadata.reference)
  File "renku/core/management/template/template.py", line 84, in fetch_templates_source
    else RepositoryTemplates.fetch(source, reference)
  File "renku/core/management/template/template.py", line 429, in fetch
    raise errors.InvalidTemplateError(f"Cannot clone template repository from {source}") from e
@Panaetius
Copy link
Member

GitReferenceNotFoundError: Cannot checkout reference 'prep-0.3.1' in repository: https://github.com/swissdatasciencecenter/renku-project-template

prep-0.3.1 is not a branch on https://github.com/swissdatasciencecenter/renku-project-template
image

@Panaetius Panaetius reopened this Mar 22, 2022
@Panaetius Panaetius changed the title InvalidTemplateError: Cannot clone template repository change cache.check_migration and cache.migrate to gracefully handle if a template repository doesn't exist anymore Mar 22, 2022
@lorenzo-cavazzi lorenzo-cavazzi self-assigned this Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants