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

fix: correctly rewrite debug container entrypoint and bind host port #6682

Merged
merged 4 commits into from
Oct 14, 2021

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Oct 5, 2021

Two issues fixed in this change:

  1. Previously, the application container's CMD was being rewritten with the debugging entrypoint. This was erroneous as it wasn't actually intercepting the entrypoint for the container. This change makes it so the actual ENTRYPOINT is being rewritten in the application container.
  2. Any allocated debugging ports were not being exposed on the host, as the host bindings were not being created. This change creates host bindings passed back from the DebugManager to the Deployer, which passes them to the PortManager to ensure no collisions go undetected. This also ensures the correct events are issued through the API, so the clients can successfully attached to the exposed debugger.

Verified using the Cloud Code Hello World Sample App.

@nkubala nkubala requested a review from a team as a code owner October 5, 2021 23:10
@nkubala nkubala requested a review from gsquared94 October 5, 2021 23:10
@google-cla google-cla bot added the cla: yes label Oct 5, 2021
@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #6682 (6f4e6f8) into main (290280e) will decrease coverage by 0.70%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6682      +/-   ##
==========================================
- Coverage   70.48%   69.77%   -0.71%     
==========================================
  Files         515      525      +10     
  Lines       23150    24009     +859     
==========================================
+ Hits        16317    16753     +436     
- Misses       5776     6157     +381     
- Partials     1057     1099      +42     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 89.00% <0.00%> (-1.82%) ⬇️
cmd/skaffold/skaffold.go 0.00% <ø> (ø)
pkg/diag/recommender/container_errors.go 0.00% <0.00%> (ø)
pkg/diag/validator/pod.go 0.00% <ø> (-1.33%) ⬇️
pkg/skaffold/build/buildpacks/logger.go 0.00% <ø> (ø)
pkg/skaffold/build/cluster/logs.go 0.00% <ø> (-16.67%) ⬇️
cmd/skaffold/app/cmd/cmd.go 70.32% <66.66%> (-0.73%) ⬇️
pkg/diag/validator/resource.go 47.05% <66.66%> (ø)
cmd/skaffold/app/cmd/debug.go 100.00% <100.00%> (ø)
pkg/skaffold/build/buildpacks/lifecycle.go 83.59% <100.00%> (ø)
... and 91 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 886f64c...6f4e6f8. Read the comment docs.

Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

It would be helpful if there were some tests to ensure the right ports were opened for an artifacts with and without debugging.

}
}

bindings, err := d.portManager.getPorts(artifact.ImageName, d.resources, containerCfg, debugBindings)
Copy link
Member

Choose a reason for hiding this comment

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

Aside: I think users will need the ability to specify additional ports to expose for our docker deployer. It might be worth turning the []string into an array of objects sooner than later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah the configuration definitely needs improvement, a []string was basically an MVP to get things working. thanks for pointing this out though, will keep a note of it

@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 12, 2021
@nkubala
Copy link
Contributor Author

nkubala commented Oct 12, 2021

It would be helpful if there were some tests to ensure the right ports were opened for an artifacts with and without debugging.

done. PTAL @briandealwis

Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

Some suggestions

@tejal29
Copy link
Contributor

tejal29 commented Oct 14, 2021

Test failed due to timeout which is fixed on master

@tejal29 tejal29 enabled auto-merge (squash) October 14, 2021 16:49
@tejal29 tejal29 disabled auto-merge October 14, 2021 16:49
@tejal29 tejal29 merged commit ee7da5b into GoogleContainerTools:main Oct 14, 2021
@nkubala nkubala deleted the docker-debug-fix branch October 18, 2021 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants