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 skaffold debug panic with nodejs #3827

Merged
merged 2 commits into from
Mar 18, 2020

Conversation

briandealwis
Copy link
Member

@briandealwis briandealwis commented Mar 13, 2020

Fixes #3821

Description
The nodejs debug transformer's IsApplicable() used the presence of NODE_VERSION to indicate that the container image is NodeJS-based. But the Apply() only handles situations where there is a npm or node invocation.

User facing changes (remove if N/A)

Look ma, no more panics!

Follow-up Work (remove if N/A)

#2141 must be solved to allow running examples/nodejs for example.

@codecov
Copy link

codecov bot commented Mar 13, 2020

Codecov Report

Merging #3827 into master will decrease coverage by 0.02%.
The diff coverage is 75.00%.

Impacted Files Coverage Δ
pkg/skaffold/debug/transform_nodejs.go 77.87% <75.00%> (-0.77%) ⬇️
cmd/skaffold/app/cmd/diagnose.go 27.77% <0.00%> (-7.23%) ⬇️
...affold/kubernetes/portforward/kubectl_forwarder.go 65.85% <0.00%> (-2.44%) ⬇️

func rewriteNodeOptions(env map[string]string, spec inspectSpec) []v1.EnvVar {
found := false
var vars []v1.EnvVar
for k, v := range env {
Copy link
Member

@loosebazooka loosebazooka Mar 16, 2020

Choose a reason for hiding this comment

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

can we do something like

nodeOptions = spec.String()
if val, ok := env["NODE_OPTIONS"]; ok {
    nodeOptions = v + " " + specString
}
env["NODE_OPTIONS"] = nodeOptions

Copy link
Member

Choose a reason for hiding this comment

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

oh you have to transform the map...

@@ -96,8 +96,7 @@ func (t nodeTransformer) Apply(container *v1.Container, config imageConfiguratio
container.Args = rewriteNpmCommandLine(config.arguments, *spec)

default:
logrus.Warnf("Skipping %q as does not appear to invoke node", container.Name)
return nil
container.Env = rewriteNodeOptions(config.env, *spec)
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, at this point, was there already some hint that this container was node? Could I be a clown and have a java application with a NODE_OPTIONS ?

Copy link
Member

Choose a reason for hiding this comment

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

you know what never mind, I read the description of the PR... 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be unusual (and discouraged) to have a mega-container with both a JVM and NodeJS application. In the k8s sphere, they should be separate containers within the same pod.

@dgageot dgageot self-assigned this Mar 18, 2020
@dgageot dgageot merged commit 91d2cb3 into GoogleContainerTools:master Mar 18, 2020
@briandealwis briandealwis deleted the dontpanic branch April 3, 2020 20:41
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.

skaffold debug panics on nodejs example
4 participants