Skip to content

Add debug events to notify of debugging containers started and terminated #3312

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

Closed

Conversation

briandealwis
Copy link
Member

@briandealwis briandealwis commented Nov 27, 2019

Relates to #3122
Fixes #2211

Description

Implements two events to notify of a debugging container being started and terminated. Also exposes a list of currently running debugging containers via the Skaffold state object. The IDEs can monitor for events to populate UIs.

`/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": "2019-11-27T21:24:55.264570Z",
    "event": {
      "buildEvent": {
        "artifact": "gcr.io/k8s-skaffold/skaffold-jib",
        "status": "In Progress"
      }
    },
    "entry": "Build started for artifact gcr.io/k8s-skaffold/skaffold-jib"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:24:57.984646Z",
    "event": {
      "buildEvent": {
        "artifact": "gcr.io/k8s-skaffold/skaffold-jib",
        "status": "Complete"
      }
    },
    "entry": "Build completed for artifact gcr.io/k8s-skaffold/skaffold-jib"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:24:57.989845Z",
    "event": {
      "deployEvent": {
        "status": "In Progress"
      }
    },
    "entry": "Deploy started"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:24:59.423482Z",
    "event": {
      "deployEvent": {
        "status": "Complete"
      }
    },
    "entry": "Deploy complete"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:25:01.828798Z",
    "event": {
      "debuggingContainerEvent": {
        "status": "Started",
        "podName": "web-6c684c7d47-2xzxd",
        "containerName": "web",
        "namespace": "default",
        "artifactImage": "gcr.io/k8s-skaffold/skaffold-jib",
        "runtime": "jvm",
        "ports": {
          "jdwp": 5005
        }
      }
    },
    "entry": "Debuggable container started pod/web-6c684c7d47-2xzxd:web (default)"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:25:50.806149Z",
    "event": {
      "debuggingContainerEvent": {
        "status": "Started",
        "podName": "web-6c684c7d47-66lct",
        "containerName": "web",
        "namespace": "default",
        "artifactImage": "gcr.io/k8s-skaffold/skaffold-jib",
        "runtime": "jvm",
        "ports": {
          "jdwp": 5005
        }
      }
    },
    "entry": "Debuggable container started pod/web-6c684c7d47-66lct:web (default)"
  }
}
{
  "result": {
    "timestamp": "2019-11-27T21:25:50.819426Z",
    "event": {
      "debuggingContainerEvent": {
        "status": "Terminated",
        "podName": "web-6c684c7d47-2xzxd",
        "containerName": "web",
        "namespace": "default",
        "artifactImage": "gcr.io/k8s-skaffold/skaffold-jib",
        "runtime": "jvm",
        "ports": {
          "jdwp": 5005
        }
      }
    },
    "entry": "Debuggable container terminated pod/web-6c684c7d47-2xzxd:web (default)"
  }
}
The `/v1/state` listing debugging containers
{
  "buildState": {
    "artifacts": {
      "gcr.io/k8s-skaffold/skaffold-jib": "Complete"
    }
  },
  "deployState": {
    "status": "Complete"
  },
  "statusCheckState": {
    "status": "Not Started"
  },
  "fileSyncState": {
    "status": "Not Started"
  },
  "debuggingContainers": [
    {
      "status": "Started",
      "podName": "web-6c684c7d47-66lct",
      "containerName": "web",
      "namespace": "default",
      "artifactImage": "gcr.io/k8s-skaffold/skaffold-jib",
      "runtime": "jvm",
      "ports": {
        "jdwp": 5005
      }
    }
  ]
}

User facing changes

n/a

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Mentions any output changes.
  • Adds documentation as needed: user docs, YAML reference, CLI reference.
  • Adds integration tests if needed.

Reviewer Notes

  • The code flow looks good.
  • Unit test added.
  • User facing changes look good.

Release Notes

n/a — for internal consumption

@codecov
Copy link

codecov bot commented Nov 27, 2019

Codecov Report

Merging #3312 into master will decrease coverage by 0.12%.
The diff coverage is 67.34%.

Impacted Files Coverage Δ
pkg/skaffold/runner/runner.go 0% <ø> (ø) ⬆️
pkg/skaffold/config/options.go 100% <ø> (ø) ⬆️
pkg/skaffold/runner/debugging.go 0% <0%> (ø)
pkg/skaffold/debug/debug.go 41.93% <0%> (-1.4%) ⬇️
cmd/skaffold/app/cmd/debug.go 46.15% <0%> (-3.85%) ⬇️
pkg/skaffold/runner/dev.go 64.6% <0%> (-2.38%) ⬇️
pkg/skaffold/debug/transform_jvm.go 94.73% <100%> (ø) ⬆️
pkg/skaffold/debug/transform_python.go 85.05% <100%> (ø) ⬆️
pkg/skaffold/debug/transform_nodejs.go 78.64% <100%> (ø) ⬆️
pkg/skaffold/debug/transform_go.go 86.17% <100%> (ø) ⬆️
... and 5 more

@briandealwis
Copy link
Member Author

PTAL @quoctruong

@briandealwis
Copy link
Member Author

@etanshaul too

@briandealwis
Copy link
Member Author

Closing. Will re-open as smaller pieces.

@briandealwis briandealwis deleted the DebugEvents branch April 18, 2020 18:20
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 should issue event with artifact debug configuration details
3 participants