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

Continue after prepare failure in tmt try #3505

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukaszachy
Copy link
Collaborator

Useful if machine needs tweaks before prepare can work, e.g. enable repos.
Fix: #2685

WDYT ? Error message needs tweaks (e.g write it in red...) but any objections against this behaviour change?

I often hit this if test requires something from beaker task library or crb isn't enabled in the image.

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

@lukaszachy lukaszachy added the command | try tmt try command label Jan 31, 2025
tmt/trying.py Outdated
try:
plan.prepare.go()
except GeneralError as error:
self.print(str(error))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The printing of the error does not feel right, how would show_exception() work for you? It should print out causes as well, and it can be told not to include tracebacks with the following patch:

diff --git a/tmt/utils/__init__.py b/tmt/utils/__init__.py
index ca322f9c..bb0f75e1 100644
--- a/tmt/utils/__init__.py
+++ b/tmt/utils/__init__.py
@@ -2775,6 +2775,7 @@ def render_exception(
 
 def show_exception(
         exception: BaseException,
+        traceback_verbosity: Optional[TracebackVerbosity] = None,
         include_logfiles: bool = True) -> None:
     """
     Display the exception and its causes.
@@ -2786,7 +2787,7 @@ def show_exception(
 
     from tmt.cli import EXCEPTION_LOGGER
 
-    traceback_verbosity = TracebackVerbosity.from_env()
+    traceback_verbosity = traceback_verbosity or TracebackVerbosity.from_env()
 
     def _render_exception(traceback_verbosity: TracebackVerbosity) -> Iterator[str]:
         yield ''
try:
    plan.prepare.go()
except GeneralError as error:
    tmt.utils.show_exception(
        error,
        traceback_verbosity=TracebackVerbosity.DEFAULT,
        include_logfiles=False
    )

It would have the advantage of reusing the existing error-logging capabilities of tmt. Maybe include_logfiles should be enabled, user probably does not care about traceback in terminal, but it might be useful to have them logged in log.txt.

Useful if machine needs tweaks before prepare can work, e.g. enable
repos.

Fix: #2685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command | try tmt try command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

try should keep the machine and ask for action on prepare failure
2 participants