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

Add a --debug flag to the CLI to help retrieve more logs. #941

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

Conversation

almet
Copy link
Contributor

@almet almet commented Oct 7, 2024

While adding Github Issue Templates on this repository (#939) we found that the commands we require the user to enter in their terminals can be quite complex. Some of them might require some bash-fu, for instance to define the location of the custom seccomp profile we are using, as it differs depending the OS.

This is a proposal to add a --debug flag to the dangerzone-cli to simplify the process of generating proper logs.

When the flag is set:

  • The RUNSC_DEBUG=1 environment variable is added to the outer container ;
  • the stderr from the outer container is attached to the exception, and displayed to the user on failures.

Info: tests are currently failing and I didn't put too much effort in making them pass, as this is here mainly to see if it could make sense to add this in the first place.

@almet almet mentioned this pull request Oct 7, 2024
Copy link
Contributor

@apyrgio apyrgio left a comment

Choose a reason for hiding this comment

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

That's a nice step towards getting debug logs from users without asking them to run weird Docker/Podman commands. I've commented on a few things that we can improve, but overall I like where this is going.

dangerzone/cli.py Outdated Show resolved Hide resolved
Comment on lines 29 to 34
def __str__(self):
msg = f"{self.error_message}"
if self.logs:
msg += f" {self.logs}"
return msg

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, this may be an overly verbose string representation of the exception. Still, I think I get why you opted to go down that road. We have a bug in the way we handle container logs on error. Basically, we don't print them to the user, even if sys.dangerzone_dev == True.

I've fixed this in #748, but it's tied to having a single container, so I can't easily cherry-pick it. Let's discuss how we can proceed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool! I believe one simple way to handle this is to wait until #748 is merged, and then rebase this branch on top of it.

Copy link
Contributor

@apyrgio apyrgio Nov 7, 2024

Choose a reason for hiding this comment

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

I think that container errors are now reported on the main branch. Give it a look and let me know if not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR will need some revisit at some point, as the main point is to add RUNSC_DEBUG=1 info to the output, making it possible to run by end users without having to do a lot of copy/paste.

When I tried to rebase this on top of the latest main, it seemed that the run was now blocked, and I didn't investigated further yet.

dangerzone/cli.py Show resolved Hide resolved
@almet
Copy link
Contributor Author

almet commented Oct 14, 2024

This seems correlated to #442.

@apyrgio
Copy link
Contributor

apyrgio commented Nov 21, 2024

We had a discussion with Alexis. He mentioned that adding the --debug flag makes the Dangezone CLI hang. The reason behind this bug is the fact that we read from stderr only after the conversion is done. However, with RUNSC_DEBUG=1, gVisor logs to stderr early, and thus the container hangs, because we don't read from the pipe.

When the flag is set, the `RUNSC_DEBUG=1` environment variable is added
to the outer container
@almet
Copy link
Contributor Author

almet commented Nov 26, 2024

I've rebased this branch on top of the latest main (actually replayed the changes manually) and it shows that it hangs.

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 this pull request may close these issues.

2 participants