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

Update to pack 0.15 and add debug support for CNB Platform API 0.4 #5064

Merged
merged 8 commits into from
Nov 30, 2020

Conversation

briandealwis
Copy link
Member

@briandealwis briandealwis commented Nov 25, 2020

Fixes: #4796

Description
Update to pack 0.15.0, and update skaffold debug to support the Cloud Native Buildpacks Platform API 0.4, the default for the CNB pack ≥ 0.13.0 and lifecycle ≥ 0.9. Platform API 0.4 changes how processes are requested in an image:

  • prior to 0.4, the entrypoint points to a launcher binary in /cnb/lifecycle/launcher, and the process is set via a CNB_PROCESS_TYPE environment variable (defaulting to web if not present)
  • with 0.4, the processes have corresponding executables in /cnb/process/xxx which are symlinks to /cnb/lifecycle/launcher. When executed, they cause the corresponding process to be run. The default process is the entrypoint (e.g., /cnb/process/web).

The Platform API version is set via the new CNB_PLATFORM_API environment variable.

User facing changes (remove if N/A)

(This doesn't actually have any user-facing changes as to this point we still link with pack 0.12 and so create images with CNB Platform API 0.3.)

@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #5064 (b288b3c) into master (7608596) will increase coverage by 0.03%.
The diff coverage is 93.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5064      +/-   ##
==========================================
+ Coverage   72.30%   72.33%   +0.03%     
==========================================
  Files         368      368              
  Lines       12927    12964      +37     
==========================================
+ Hits         9347     9378      +31     
- Misses       2890     2893       +3     
- Partials      690      693       +3     
Impacted Files Coverage Δ
pkg/skaffold/debug/transform.go 90.00% <83.33%> (+0.10%) ⬆️
pkg/skaffold/debug/cnb.go 91.25% <91.07%> (-1.35%) ⬇️
pkg/skaffold/build/buildpacks/fetcher.go 66.66% <100.00%> (+8.33%) ⬆️
pkg/skaffold/build/buildpacks/lifecycle.go 82.35% <100.00%> (+0.63%) ⬆️
pkg/skaffold/docker/image.go 79.53% <0.00%> (-1.40%) ⬇️

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 7608596...a2e555b. Read the comment docs.

tejal29
tejal29 previously approved these changes Nov 25, 2020
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

LGTM.

// indicates an image mis-configuration as we should have resolved the the
// CNB_PROCESS_TYPE (if specified) or `web`.
logrus.Warnf("no CNB launch found for %s/%s", ic.artifact, processType)
logrus.Warnf("no CNB launch found for %s", ic.artifact)
Copy link
Contributor

Choose a reason for hiding this comment

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

would it possible to debug a container if CNB launch is not found?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. At this point we have an CNB launcher entrypoint (either /cnb/lifecycle/launcher or /cnb/process/xxx), but no corresponding process found. So we don't have a command-line should be executed.

Basically we'll return, the debug transforms won't be able to figure anything out, and the container / pod will remain un-touched. And the execution of the container will then fail as no process definition will be found.

// the original form.
// Script-style launches support referencing environment variables since they are expanded by the shell.
//
// Configuring the launch depends on the CNB Platform API version being used, which is determined by
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the details, it was a little bit easier to understand the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Going through this was painful :-)

@briandealwis briandealwis changed the title Add debug support for CNB Platform API 0.4 Update to pack 0.15 and add debug support for CNB Platform API 0.4 Nov 26, 2020
@briandealwis briandealwis dismissed tejal29’s stale review November 27, 2020 19:46

Integration tests are failing; marking as draft and fixing

@briandealwis briandealwis marked this pull request as draft November 27, 2020 19:46
Tests were failing as I wasn't rewriting the entrypoint, so that
Platform 0.4-style process executables (/cnb/process/web) continued
through and the debug transformers wouldn't recognize the executable.

- fix adjustCommandLine() and add tests
- fix testutil.isNil to handle function pointers
- narrow isCNBImage() to only allow entrypoint to be 1-element array
  and add tests
- go style nits (rename isCnbImage -> isCNBImage, godoc style)
@briandealwis
Copy link
Member Author

Marking TestDevPortForwardDeletePod to be skipped #4733.

@briandealwis briandealwis marked this pull request as ready for review November 30, 2020 20:29
Copy link
Contributor

@nkubala nkubala left a comment

Choose a reason for hiding this comment

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

this LGTM, its essentially an improved version of similar changes I made in #5038. thanks for the detailed comments @briandealwis

@nkubala nkubala merged commit e91c8e6 into GoogleContainerTools:master Nov 30, 2020
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.

Debug needs to work with CNB Platform v0.4 and the new launcher style
3 participants