Skip to content

[tmpnet] Avoid port forwarding when running in a kube cluster #3997

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

Merged
merged 2 commits into from
Jun 6, 2025

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Jun 5, 2025

Why this should be merged

Previously port forwarding was always used to communicate with a node even when a test workload was running inside a kube cluster (assumed to be the same cluster hosting the avalanchego nodes). Now the pod IP will be used if running in a kube cluster (as indicated by a service account token is observed on the local filesystem). This avoids the overhead of tunneling through the kube API when not needed.

How this was tested

CI

Need to be documented in RELEASES.md?

N/A

Previously port forwarding was always used to communicate with a node
even when a test workload was running inside a kube cluster (assumed
to be the same cluster hosting the avalanchego nodes). Now the pod IP
will be used if running in a kube cluster (as indicated by a service
account token is observed on the local filesystem). This avoids the
overhead of tunneling through the kube API when not needed.
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 19:35
Copy link
Contributor

@Copilot Copilot AI left a comment

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 refactors how the application connects to nodes when running within a Kubernetes cluster by using the pod's direct IP and staking address, thereby avoiding unnecessary port forwarding.

  • Replaced TODO comments with logic to use direct pod URIs in GetLocalURI and GetLocalStakingAddress when running in-cluster.
  • Introduced a new helper function, isRunningInCluster, to determine if the test is running inside a Kubernetes cluster.

@maru-ava maru-ava self-assigned this Jun 5, 2025
@maru-ava maru-ava added the tooling Build, test and development tooling label Jun 5, 2025
@maru-ava maru-ava moved this to Ready 🚦 in avalanchego Jun 5, 2025
@yacovm yacovm added this pull request to the merge queue Jun 5, 2025
@yacovm yacovm removed this pull request from the merge queue due to a manual request Jun 5, 2025
@yacovm
Copy link
Contributor

yacovm commented Jun 5, 2025

whoops, jumped the 🔫

@yacovm yacovm added this pull request to the merge queue Jun 6, 2025
Merged via the queue into master with commit 9719254 Jun 6, 2025
27 checks passed
@yacovm yacovm deleted the tmpnet-running-in-cluster branch June 6, 2025 17:26
@github-project-automation github-project-automation bot moved this from Ready 🚦 to Done 🎉 in avalanchego Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling Build, test and development tooling
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants