Skip to content

feat: add pprof profiling support to interlink, virtual-kubelet, and ssh-tunnel components#534

Open
ShantKhatri wants to merge 2 commits into
interlink-hq:mainfrom
ShantKhatri:feat/issue-400
Open

feat: add pprof profiling support to interlink, virtual-kubelet, and ssh-tunnel components#534
ShantKhatri wants to merge 2 commits into
interlink-hq:mainfrom
ShantKhatri:feat/issue-400

Conversation

@ShantKhatri

Copy link
Copy Markdown

Fixes #400

Summary

This PR adds basic pprof profiling to all three long-running components, interlink, virtual-kubelet, and ssh-tunnel, as a starting point for #400 .

The approach is intentionally simple is as a shared pkg/pprof helper spins up a background HTTP server that exposes Go's standard /debug/pprof/ endpoints. This uses net/http/pprof (the HTTP wrapper around runtime/pprof) which is the lowest-friction way to get profiling working without touching existing server code.

Profiling is off by default. Each component can opt in via:

  • A Pprof: block in the YAML config (for interlink and virtual-kubelet)
  • CLI flags -pprof, -pprof-port, -pprof-address (for ssh-tunnel)
  • Env vars ENABLE_PPROF, PPROF_PORT, PPROF_ADDRESS (all three)

Default ports are 6060 (vk), 6061 (interlink), 6062 (ssh-tunnel) to avoid conflicts when running everything on the same host.

This is intentionally the "easy first step". Down the line we could look at file-based runtime/pprof captures for scheduled/offline profiling, or auth-gating the endpoints for production hardening, but those feel like follow-ups once we've validated the basics work.


Related issue : #400

…ssh-tunnel components

Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
Copilot AI review requested due to automatic review settings June 29, 2026 16:59
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for interlink-dev canceled.

Name Link
🔨 Latest commit 31b8d50
🔍 Latest deploy log https://app.netlify.com/projects/interlink-dev/deploys/6a42ac4275d2c300084303e9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces basic Go pprof HTTP profiling support across the long-running interLink components (interlink, virtual-kubelet, ssh-tunnel) by adding a shared helper and wiring it into each component with config/flag/env-based enablement.

Changes:

  • Added a shared pkg/pprof helper that starts a background net/http/pprof server tied to a context.
  • Extended interlink and virtual-kubelet YAML configs with a Pprof block (and added env-var overrides for interlink; env-var overrides are applied in vk main).
  • Added CLI flags + env-var overrides to enable/parameterize pprof for ssh-tunnel, plus unit tests for pkg/pprof.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/virtualkubelet/config.go Adds PprofConfig and embeds it in the VK config struct for YAML-driven pprof settings.
pkg/pprof/pprof.go Introduces the shared pprof server starter helper.
pkg/pprof/pprof_test.go Adds tests to validate pprof server start/disabled behavior.
pkg/interlink/config.go Adds PprofConfig and supports env-var overrides in interlink config loading.
cmd/virtual-kubelet/main.go Wires pprof startup into virtual-kubelet with YAML + env-var overrides and default values.
cmd/ssh-tunnel/main.go Adds pprof CLI flags, env-var overrides, and starts the pprof server.
cmd/interlink/main.go Starts the pprof server based on loaded config defaults/overrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/pprof/pprof.go
Comment thread pkg/pprof/pprof.go
Comment thread pkg/pprof/pprof_test.go
Comment thread pkg/pprof/pprof_test.go
… and updated address parsing

Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
@ShantKhatri

Copy link
Copy Markdown
Author

Hi @dciangot, changes here are ready for review when you get a chance.

One note: we're suppressing gosec G108 in the pprof import; it's a false positive, since exposing /debug/pprof/ is exactly the intent here. Server defaults to 127.0.0.1, so no external exposure unless explicitly configured.

@ShantKhatri ShantKhatri marked this pull request as ready for review June 29, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add pprof options

2 participants