Wire up debug events#3645
Conversation
- adds SkaffoldRunner.isDebugMode()
Codecov Report
|
pkg/skaffold/runner/debugging.go
Outdated
| // isDebugMode returns true if we're running for debugging. | ||
| func (r *SkaffoldRunner) isDebugMode() bool { | ||
| return r.runCtx.Opts.Command == "debug" | ||
| } |
There was a problem hiding this comment.
I introduced this function to test whether Skaffold was launched as skaffold debug. This works for debug, but it doesn't seem a great pattern — for example, debug effectively invokes dev under the hood.
There was a problem hiding this comment.
nit: we already have a runContext.DevMode that serves a similar purpose. Can we make this similar? I don't have a preference towards either, I just don't want inconsistency.
| // Notify only when a container is Running or Terminated (not Waiting) | ||
| // "ADDED" is never interesting since no containers are Running yet | ||
| // "MODIFIED" may now have containers in Running or Terminated | ||
| // "DELETED" if the pod is deleted | ||
| if evt.Type != watch.Modified && evt.Type != watch.Deleted { | ||
| continue | ||
| } |
There was a problem hiding this comment.
What I observed when prototyping this functionality that I couldn't rely on the pod status. Rather I had to check on pod MODIFIED and DELETED events and then look at and track the individual container status (see below in checkPod()). I would get spurious debug events otherwise.
balopat
left a comment
There was a problem hiding this comment.
LGTM, tried it and works
82f5168 to
1af9841
Compare
1af9841 to
e610746
Compare
|
Hmm...the new test just flaked: |
I'm worried about the flake of TestDebugEventsRPC
balopat
left a comment
There was a problem hiding this comment.
we need to figure out what broke with --status-check=true that just got merged to be the default.
|
So the cause is that I deviate from port-forwarding's watch event filtering, which looks at ADDED and MODIFIED events, whereas the container manager only looks at MODIFIED and DELETED watch events. Prior to the status checks, ADDED events seemed spurious as they had no Removing this watch event filtering and using only the container status makes everything work again. |
|
PTAL @balopat |
Relates to #3122 (#3564, #3609)
Fixes #2211
Description
This PR wires up the new
DebuggingContainerEvent(#3609) to be fired by Skaffold when observing a debuggable container starting or terminating. These debugging containers are exposed via the Skaffold state object. With this PR, the IDEs can monitor for events to populate UIs.User facing changes
New events and addition to the Skaffold state.
There are no changes to the log. Although some logging may be useful for users seeking to configure their debuggers manually, I figured the port-forwarding messages would usually be sufficient.
`/v1/events` stream of `skaffold debug` within `examples/jib`
In this example, we do a
skaffold debug, and then kill the deployed pod. The deployment starts a new pod. We get a terminated event for the container for the killed pod.{ "result": { "timestamp": "2020-02-05T03:27:30.114354Z", "event": { "debuggingContainerEvent": { "status": "Started", "podName": "web-f6d56bcc5-6csgs", "containerName": "web", "namespace": "default", "artifact": "skaffold-jib", "runtime": "jvm", "debugPorts": { "jdwp": 5005 } } }, "entry": "Debuggable container started pod/web-f6d56bcc5-6csgs:web (default)" } }The `/v1/state` listing debugging containers
{ "buildState": { "artifacts": { "skaffold-jib": "Complete" } }, "deployState": { "status": "Complete" }, "forwardedPorts": { "5005": { "localPort": 5005, "remotePort": 5005, "podName": "web-f6d56bcc5-6csgs", "containerName": "web", "namespace": "default", "portName": "jdwp", "resourceType": "pod", "resourceName": "web-f6d56bcc5-6csgs", "address": "127.0.0.1" }, "8080": { "localPort": 8080, "remotePort": 8080, "namespace": "default", "resourceType": "service", "resourceName": "web", "address": "127.0.0.1" }, "8081": { "localPort": 8081, "remotePort": 8080, "podName": "web-f6d56bcc5-6csgs", "containerName": "web", "namespace": "default", "resourceType": "pod", "resourceName": "web-f6d56bcc5-6csgs", "address": "127.0.0.1" } }, "statusCheckState": { "status": "Not Started" }, "fileSyncState": { "status": "Not Started" }, "debuggingContainers": [ { "status": "Started", "podName": "web-f6d56bcc5-6csgs", "containerName": "web", "namespace": "default", "artifact": "skaffold-jib", "runtime": "jvm", "debugPorts": { "jdwp": 5005 } } ] }Next PRs.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
Adds documentation as needed: user docs, YAML reference, CLI reference.already doneReviewer Notes
Release Notes