Skip to content

Conversation

@hunter-ni
Copy link
Contributor

@hunter-ni hunter-ni commented Nov 20, 2025

What does this Pull Request accomplish?

This set of changes adds awareness of the NIDiscovery_ClusterId environment variable to the existing DiscoveryClient, allowing the DiscoveryClient to properly detect a Discovery Service that has been launched with the specified cluster ID.

If this variable is set in the environment of a launched Discovery Service process, then the Discovery Service will identify itself as having a cluster ID equal to the value of the environment variable, adding a key file on disk that includes that cluster ID in its name. (Note that launching a Discovery Service with a unique cluster allows multiple Discovery Services to run and be interacted with independently on a machine, which is particularly helpful for testing and example/demonstration scenarios.)

Prior to these changes, the DiscoveryClient would always look for the key file on disk for the default cluster, despite the fact that if the DiscoveryClient were to allow the Discovery Service to launch in this scenario (with the environment variable set), it would do so with a different cluster--the one specified in the environment variable that the Discovery Service itself already honors.

With these changes, the DiscoveryClient now looks for the appropriate key file in both cases:

  • If the environment variable is not set, then os.environ.get("NIDiscovery_ClusterId") will return None and we will look for the default key file (as we determine whether to launch a new Discovery Service process).
  • If the environment variable is set, then os.environ.get("NIDiscovery_ClusterId") will return the cluster ID and we will look for the key file that pertains to that particular cluster (as we determine whether to launch a new Discovery Service process).

Why should this Pull Request be merged?

This PR improves support of the DiscoveryClient when used in conjunction with a Discovery Service with a non-default cluster.

What testing has been done?

Exercising the modified code in both cases: when the environment variable is set and when it is not set

…ent variable (used by the Discovery Service for initializing its cluster ID) to determine whether the key file exists to indicate an already launched Discovery Service.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Test Results

  120 files  ±0    120 suites  ±0   3m 25s ⏱️ +8s
  249 tests ±0    247 ✅ ±0   2 💤 ±0  0 ❌ ±0 
2 490 runs  ±0  2 460 ✅ ±0  30 💤 ±0  0 ❌ ±0 

Results for commit 2728161. ± Comparison against base commit f632506.

♻️ This comment has been updated with latest results.

Copy link
Contributor

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 adds support for the NIDiscovery_ClusterId environment variable to the DiscoveryClient, enabling it to properly detect and interact with Discovery Services launched with non-default cluster IDs. This enhancement is particularly valuable for testing and demonstration scenarios where multiple Discovery Services need to run independently on the same machine.

Key Changes:

  • Added reading of the NIDiscovery_ClusterId environment variable in _get_discovery_service_address()
  • The cluster ID is now passed to _get_key_file_path() to locate the correct key file for the specified cluster

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

@hunter-ni hunter-ni requested a review from bkeryan November 20, 2025 21:32
@hunter-ni hunter-ni merged commit 8c31544 into main Nov 21, 2025
348 checks passed
@hunter-ni hunter-ni deleted the users/hunter-ni/discovery-client-cluster-id branch November 21, 2025 15:20
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.

5 participants