GoogleContainerTools / GoogleContainerTools/skaffold

`debug` should rewrite command-lines to remove 'exec'

Open
#7,168 1 comment 1 reaction 0 assignees View on GitHub
area/debug area/logging kind/friction
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

Motivated by [a problem on stackoverflow](), where the user's Dockerfile had `CMD exec gunicorn ...`. The Python debug launcher does not strip out the `exec` and so the launch fails.

Normally this is somewhat self-evident from the logs:
```
Waiting for deployments to stabilize...
- pods: waiting for init container install-python-debug-support to start
- pod/python3: waiting for init container install-python-debug-support to start
- pods: container python3-web terminated with exit code 1
- pod/python3: container python3-web terminated with exit code 1
> [python3 python3-web] time="2022-03-08T15:24:02Z" level=warning msg="unable to determine launcher: could not find launcher \"exec\": exec: \"exec\": executable file not found in $PATH"
> [python3 python3-web] time="2022-03-08T15:24:02Z" level=fatal msg="error launching python debugging: exec: \"exec\": executable file not found in $PATH"
- pods failed. Error: container python3-web terminated with exit code 1.
```

But the logs are more hit-and-miss with the Cloud Run emulator in Cloud Code, where I usually see logs like:
```
Waiting for deployments to stabilize...
Deploy completed in 2.538 seconds
- deployment/t: waiting for init container install-python-debug-support to start
- pod/t-7677684866-kbrlx: waiting for init container install-python-debug-support to start
- deployment/t: container t-container terminated with exit code 1
- pod/t-7677684866-kbrlx: container t-container terminated with exit code 1
> Error retrieving logs for pod t-7677684866-kbrlx: exit status 1.
Try `kubectl logs t-7677684866-kbrlx -n default -c t-container`
- deployment/t failed. Error: container t-container terminated with exit code 1.
```

### Strategy

We have some command-line rewriting for the Buildpacks case. This could be generalized into a set of transformations, one of which would strip off `exec`, and another of which might handle `env A=B ...` too? Or maybe recognize and error on patterns that won't work, like `sh -c '...'` or `... && ...`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.