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
Debug ports should be configurable #4419
Comments
Thanks for the feedback @cpvandehey! How were you thinking this configuration would look like? What should happen if the debug port is unavailable? Should |
In the skaffold.yaml docs there is a section called
Yeah, I have some opinions here. Most apps that allow specific port selection error out when another process is hanging onto the port. I suggest following that pattern. BTW, I can certainly help contribute, but I am not sure if I am "allowed" to yet by my employer and the google container tools crew. You all made slick tools and I'd love to help out/write some go for once. |
@cpvandehey Have you tried adding an explicit |
This does work, but This is what happens in the python command: |
A different port will only be used if there is another container in the same pod using the port, and |
I agree with your analysis. This is what I believe should be configurable. The defaults are fine when you work with one project and one project only. It does not scale well when you'd like each project to have an independent and specific debug port that you can configure VScode to use within each repo (potentially even committing the |
Please confirm if the issue makes sense. I can certainly provide more specific examples |
I'm reluctant to introduce a What would make more sense to me is to add support for BTW: are you using Cloud Code for VSCode? It uses Skaffold under the hood and leverages Skaffold's APIs to automatically connect debug sessions. |
Perhaps I'm not making a clear enough point or I am misunderstanding how this works. Let me be a tad more verbose. Thanks for your patience and willingness to understand this!
You're 100% right that it works, but the DX is not quite there. It works well with one project running in debug mode. You can always expect it to claim a port on the running pod, forward it to local host on port Again, I am happy to know that this reliably works and I can launch more projects that have dynamic port allocation, but this is a bad DX when I have many projects that should have consistent configuration. Suppose I have 10 microservices to run/debug locally that are going to use skaffold. Instead of having specifically defined ports that each use on every launch regardless of the order, I have to accept the reality that the debug ports can change based on the order in which I launch the projects (which eventually leads to more manual configuration at the time of debugging). For ex:
With regards to your suggestions on using -- I can try out Cloud Code to see if that abstracts away all of this. It looks really useful (especially because its supported by all popular IDEs for a super flexible DX). |
Just to be clear, my suggestion is this:
For example, with 3 containers in podA, podB, podC, your portForward:
- resourceType: pod
resourceName: podA
port: 5678
localPort: 7000
- resourceType: pod
resourceName: podB
port: 5678
localPort: 7001
- resourceType: pod
resourceName: podC
port: 5678
localPort: 7002 You then set up your launch.json to use those local ports (7000 – 7002). Note that the remote port for each pod is fixed 5678. Since you control the pod names (podA, podB, podC) then you choose how to map projects to local ports, and so you maintain the correlation to your Two notes to the above:
So if this doesn't work for you, I'd appreciate a sketch of what your application looks like in terms of k8s resources and your containers.
To the contrary, it would require significant effort and change within Skaffold. Our focus is instead to surface debugging information to be used by tools like Cloud Code to spare humans from managing this port mapping toil. And note that when a container is redeployed (e.g., you use a deployment, and the original pod is terminated), the old container continues to occupy the original local debug port until it is terminated, and so the new container will not be mapped to the original local port. |
Ah. This example makes sense. Thank you for writing that out and for your patience! -- I just finished watching a cloud code demo at NEXT. I'm leaning towards just setting it up now. |
We can close this as there are multiple workarounds. Thanks again |
Expected behavior
I am using python and the MS
ptvsd
package. It works well with skaffold and VSCode, but it does not scale well in a platform setting with regards to debugging multiple services at once.skaffold
is smart enough to dynamically find different ports when a developer launches more than once project, but the port selected for debugging should be configurable to keep consistency.Here is the code that selects a default port
5678
if no ptvsd command already exists. The skaffold configuration should be setup to specify ports on a per project basis that remain CONSISTENT. In the end, a developer should be able to set up a debug configuration once within a project and never have to change it based on how many other services are running in parallel.The text was updated successfully, but these errors were encountered: