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

It isn't possible to debug Python Django application #13816

Closed
tolusha opened this issue Jul 11, 2019 · 22 comments
Closed

It isn't possible to debug Python Django application #13816

tolusha opened this issue Jul 11, 2019 · 22 comments
Labels
area/plugin-registry kind/bug Outline of a bug - must adhere to the bug report template. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. severity/P2 Has a minor but important impact to the usage or development of the system. status/info-needed More information is needed before the issue can move into the “analyzing” state for engineering.
Milestone

Comments

@tolusha
Copy link
Contributor

tolusha commented Jul 11, 2019

Description

It isn't possible to debug Python Django application. When Python debug adapter starts debug session for Django application it sends runInTerminal request which starts a django server in side-car container. Since there aren't needed dependencies in the container it fails to start and debug session isn't initialized.

Actually this is a common problem and many debug adapter will face it.

Reproduction Steps

  1. Create workspace from python-django dev file [1]
  2. Run commands to install dependencies, patch resources and migration
  3. Create debug configuration (see below)
  4. Try to start debug session
  5. Debug failed

[1] https://github.com/eclipse/che-devfile-registry/blob/master/devfiles/python-django/devfile.yaml

OS and version:
Che-7.0.0-rc-4-snapshot

Diagnostics:

        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "args": [
                "runserver",
                "--noreload"
            ],
            "django": true
        }
@tolusha tolusha added the kind/bug Outline of a bug - must adhere to the bug report template. label Jul 11, 2019
@tsmaeder
Copy link
Contributor

tsmaeder commented Jul 11, 2019

@tolusha the "runInTerminal" request is part of the DAP, right? Am I correct that this goes to the theia container and is then routed to the container running the python extension? I think that routing is wrong, conceptually: the tooling container should contain stuff to run the tooling, nothing more.

@tsmaeder
Copy link
Contributor

@tolusha can you start a remote debug session?

@tsmaeder tsmaeder added the status/info-needed More information is needed before the issue can move into the “analyzing” state for engineering. label Jul 11, 2019
@tsmaeder
Copy link
Contributor

This would be 7.0.0 for me if we cannot debug at all. If we have a workaround, 7.1.0

@tolusha
Copy link
Contributor Author

tolusha commented Jul 12, 2019

@tsmaeder

the "runInTerminal" request is part of the DAP, right? Am I correct that this goes to the theia container and is then routed to the container running the python extension

correct

I think that routing is wrong, conceptually: the tooling container should contain stuff to run the tooling, nothing more.

That's arguable. Sidecar container doesn't know anything about other containers.

can you start a remote debug session?

No, I wasn't able.
I will try.

@tolusha
Copy link
Contributor Author

tolusha commented Jul 12, 2019

So, It is possible establish a remote debug session.
At least I can do it in VS Code and Theia IDE, but with Che Theia I got:

Uncaught (in promise) Error: It is not possible to provide debug adapter executable for 'python'. (version: 7.0.0-rc-3.0). This very error has been fixed in recent versions of Theia. But, when I used the latest version of Che Theia I got: Uncaught (in promise) Error: Unknown method $activateByEvent on actor PluginManagerExt

@benoitf Is it something familiar for you?

@tsmaeder
Copy link
Contributor

$activateByEvent is related to activation events being implemented in theia master. It's not in the
theia che-7.0.0 branch.

If we don't have a workaround, we need to escalate.

@tolusha
Copy link
Contributor Author

tolusha commented Jul 12, 2019

We need the latest Theia version

@tsmaeder tsmaeder added this to the 7.0.0 milestone Jul 18, 2019
@l0rd
Copy link
Contributor

l0rd commented Jul 18, 2019

Why aren't we defining the launch config in the devfile as described here.

@metlos and @RomanNikitenko have worked on handling that (transforming a che command in a vscode launch or task config). We should use that right?

@l0rd
Copy link
Contributor

l0rd commented Jul 18, 2019

Oh that's already in Che documentation as well.

@tolusha
Copy link
Contributor Author

tolusha commented Jul 19, 2019

@l0rd
Cool, make sense. I haven't noticed this feature

@tolusha
Copy link
Contributor Author

tolusha commented Jul 19, 2019

I am working on workaround and I will prepare a PR soon.

@tsmaeder
Copy link
Contributor

The issue is still there, even if we have a workaound.

@tsmaeder tsmaeder modified the milestones: 7.0.0, 7.1.0 Jul 22, 2019
@tsmaeder
Copy link
Contributor

Retargeting to 7.1.0

@l0rd
Copy link
Contributor

l0rd commented Jul 22, 2019

@tolusha @tsmaeder can one of you describe the workaround here to help those that have the same issue?

@tolusha
Copy link
Contributor Author

tolusha commented Aug 16, 2019

Currently I am working on redirection runInTerminal request to a dev container. The request above is used to run an application to debug. Current impediments are:

  • using an env variable which will point to the dev container [1]. The env variables might be configured in a devfile [2]
  • both dev and sidecar containers should use the same version of python
  • debug configuration must be adjusted by adding a pythonPath attribute which points to a
    python in the dev container:
{
        "name": "Python: Django",
        "pythonPath": "/usr/bin/python",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/django-realworld-example-app/manage.py",
        "args": [
            "runserver",
            "--noreload"
        ],
        "django": true
    },
  • It is necessary to share /tmp/vscode-unpacked folder files between sidecar and dev containers since it is used to run the application:

error

[1] https://github.com/eclipse/che-theia/blob/master/extensions/eclipse-che-theia-plugin-remote/src/node/terminal-container-aware.ts#L59
[2] #12555

@tsmaeder
Copy link
Contributor

debug configuration must be adjusted by adding a pythonPath attribute which points to a
python in the dev container:

Shouldn't this be an attribute of the python dev container somehow?

It is necessary to share /tmp/vscode-unpacked folder files between sidecar and dev containers since it is used to run the application:

No, we should use the version of python that is installed in the dev container, IMO.

@tolusha
Copy link
Contributor Author

tolusha commented Aug 16, 2019

No, we should use the version of python that is installed in the dev container, IMO.

It isn't a problem. The problem is that python uses some files from /tm/vscode-unpacked to run the application. These files comes with extensions.

@tsmaeder
Copy link
Contributor

@tolusha you'd have to be more concrete here: what exactly is going on here? I don't understand.

@tolusha
Copy link
Contributor Author

tolusha commented Aug 16, 2019

Have a look at screenshot. That is the command is run in dev container to start the app.
#13816 (comment)

@tsmaeder
Copy link
Contributor

@benoitf @evidolob this would bring us back to the state where plugins are installed in a folder shared by all containers (kind of).

@tsmaeder tsmaeder mentioned this issue Aug 29, 2019
41 tasks
@tsmaeder tsmaeder added area/plugin-broker severity/P2 Has a minor but important impact to the usage or development of the system. labels Sep 3, 2019
@amisevsk
Copy link
Contributor

amisevsk commented Sep 3, 2019

@tolusha As a test, is this issue resolved if you add a /tmp/vscode-unpacked/ volume to the workspace devfile?

Currently the only folder shared between theia and sidecars in the /plugins folder. If we also need vscode-unpacked then that's a fairly significant change.

@che-bot
Copy link
Contributor

che-bot commented Jun 17, 2020

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 17, 2020
@che-bot che-bot closed this as completed Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin-registry kind/bug Outline of a bug - must adhere to the bug report template. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. severity/P2 Has a minor but important impact to the usage or development of the system. status/info-needed More information is needed before the issue can move into the “analyzing” state for engineering.
Projects
None yet
Development

No branches or pull requests

6 participants