Skip to content

[tmpnet] Ensure GetNodeURIs returns locally-accessible URIs to ensure kube compatibility #3973

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 6 commits into from
May 21, 2025

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented May 20, 2025

PR Chain: tmpnet+kube

This PR chain enables tmpnet to deploy temporary networks to Kubernetes. Early PRs refactor tmpnet to support the addition in #3615 of a new tmpnet node runtime for kube.

Why this should be merged

Previously it was possible to use TestEnvironment.URIs to access node API endpoints. If a node is running in a kube cluster, however, it won't be accessible via direct URI from outside that cluster. Adding TestEnvironment.GetNodeURIs and updating callers to use that ensures URIs that will work regardless of the location of nodes and test workloads.

How this was tested

CI

Need to be documented in RELEASES.md?

N/A

Previously it was possible to use TestEnvironment.URIs to access node
API endpoints. If a node is running in a kube cluster, however, it
won't be accessible from outside that cluster. Adding
TestEnvironment.GetLocalNodeURIs and updating callers to use that
ensures URIs that will work regardless of the location of nodes and
test workloads.
@maru-ava maru-ava self-assigned this May 20, 2025
@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 17:30
@maru-ava maru-ava added testing This primarily focuses on testing tooling Build, test and development tooling labels May 20, 2025
@maru-ava maru-ava moved this to Ready 🚦 in avalanchego May 20, 2025
Copy link

@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 replaces the use of TestEnvironment.URIs with the new GetLocalNodeURIs to ensure that API endpoints are accessible in Kubernetes environments. Key changes include adding the GetLocalNodeURIs function and updating all callers (in fixtures, e2e, and antithesis tests) to use the local URIs instead of public ones.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/fixture/tmpnet/utils.go Added GetLocalNodeURIs function and adjusted GetNodeURIs for better node status checking
tests/fixture/tmpnet/network.go Added wrapper method on Network to use GetLocalNodeURIs
tests/fixture/e2e/env.go Removed URIs field; added GetLocalNodeURIs for TestEnvironment and updated GetRandomNodeURI
tests/e2e/x/transfer/virtuous.go Updated to use local URIs for API calls
tests/e2e/p/validator_sets.go Updated to use local URIs for platformvm client initialization
tests/antithesis/config.go Updated configuration logic to use local URIs
Comments suppressed due to low confidence (1)

tests/e2e/env.go:257

  • Consider adding a check to ensure that 'availableNodes' is not empty before selecting a random node to avoid an index out of range panic.
randomNode := availableNodes[r.Intn(len(availableNodes))]

@@ -46,8 +46,6 @@ type TestEnvironment struct {
RootNetworkDir string
// The directory where the test network configuration is stored
NetworkDir string
// URIs used to access the API endpoints of nodes of the network
URIs []tmpnet.NodeURI
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Requiring access via a function instead of a field ensures the caller is always provided locally-accessible URIs whether nodes are running as processes or as pods in a kube cluster.

Comment on lines 56 to 57
// GetNodeURIs returns the URIs of the given nodes provided they are running and not ephemeral. Prefer
// GetLocalNodeURIs if targeting nodes that could be running in a Kubernetes cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it'd make sense to elaborate on the function doc? From my understanding, GetLocalNodeURIs() returns the URIs of available nodes running locally (e.g. inside a process runtime). However, the current doc for GetNodeURIs() doesn't make clear (IMO) what is offers when compared to GetLocalNodeURIs().

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with Rodrigo.

@maru-ava
Copy link
Contributor Author

Fair points, updated to address review comments, PTAL.

Always fine to ask questions, and there are additional strategies for discovering context independently e.g.

  • git blame GetLocalURI to find the PR that introduced it
  • realize that the kube runtime PR will be required to provide an implementation of GetLocalURI and compare its implementation with the process runtime's

@maru-ava maru-ava changed the title [tmpnet] Replace GetNodeURIs with GetLocalNodeURIs for kube compat [tmpnet] Ensure GetNodeURIs returns locally-accessible URIs to ensure kube compatibility May 21, 2025
@maru-ava maru-ava added this pull request to the merge queue May 21, 2025
Merged via the queue into master with commit ae36212 May 21, 2025
25 checks passed
@maru-ava maru-ava deleted the tmpnet-local-node-uris branch May 21, 2025 17:11
@github-project-automation github-project-automation bot moved this from Ready 🚦 to Done 🎉 in avalanchego May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing tooling Build, test and development tooling
Projects
Status: Done 🎉
Development

Successfully merging this pull request may close these issues.

3 participants