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

feat: handle migration errors from the template #2819

Merged
merged 8 commits into from Apr 14, 2022

Conversation

lorenzo-cavazzi
Copy link
Member

@lorenzo-cavazzi lorenzo-cavazzi commented Apr 8, 2022

/deploy renku=auto-update/renku-core-1.2.1 #persist

Description

This PR improves the UX when a project's template cannot be checked out correctly. It adds new errors and some basic indications to the user in both the CLI and the service. The 2 new cases handled properly are:

Screenshot_20220412_174611

fix #2769

@RenkuBot
Copy link
Contributor

RenkuBot commented Apr 8, 2022

You can access the deployment of this PR at https://renku-ci-rp-2819.dev.renku.ch

@lorenzo-cavazzi lorenzo-cavazzi marked this pull request as ready for review April 12, 2022 15:47
@lorenzo-cavazzi lorenzo-cavazzi requested a review from a team as a code owner April 12, 2022 15:47
Copy link
Contributor

@m-alisafaee m-alisafaee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Lorenzo! Please see my comments.

@@ -420,6 +420,10 @@ def fetch(cls, source: Optional[str], reference: Optional[str]) -> "RepositoryTe
try:
repository = clone_repository(url=source, path=path, checkout_revision=reference, install_lfs=False)
except errors.GitError as e:
if "Cannot checkout reference" in str(e):
raise errors.TemplateMissingReferenceError(
f"Cannot find the reference {reference} in the template repository from {source}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference {reference} -> reference '{reference}' so that it's more visible what the reference is.

message = f"{str(e)}; You can still manually update the template and set a difference reference."
raise errors.TemplateUpdateError(message)
except errors.InvalidTemplateError:
raise errors.TemplateUpdateError("Template cannot be fetched.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to convert these errors to TemplateUpdateError? I believe we don't need to catch them here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to simplify catching/handling them in the service and in the CLI. For the latter, throwing a new error results in a clean error message, while not doing it means a long and confusing stack trace is printed (see screen below).
Is there a better way to handle this? Or maybe that should be done in the cli code?
Screenshot_20220413_134606

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It's fine to do it here.

@wraps(f)
def decorated_function(*args, **kwargs):
"""Represents decorated function."""
# NOTE: verify if this may better go in MigrationsCheckCtrl as try/except in to_response()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this comment. Is it a left-over TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch! Yes, that is a leftover, thanks for spotting it!



@handle_migration_read_errors
def handle_migration_write_errors(f):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to distinguish between migration read/write errors. AFAIK, the difference is that in read we only check for migration; so, the same errors can happen in both cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The write section handles a couple of extra errors, and those throw a more severe error (Program instead of Intermittent).
The point is that errors while reading are somewhat expected (e.g. template may be deleted, that's not a bug), while actually migrating the project should be invoked by the client only if the read errors didn't happen.
So a DockerfileUpdateError or a MigrationError caught on writing is likely to be a bug or severe error from which the user may not be able to recover in the UI.

Copy link
Contributor

@m-alisafaee m-alisafaee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@lorenzo-cavazzi lorenzo-cavazzi merged commit 1ddc16e into develop Apr 14, 2022
@lorenzo-cavazzi lorenzo-cavazzi deleted the 2769-migration-errors branch April 14, 2022 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants