fix: rio CLI reads ETCD_ENDPOINT and connect to it - #562
Open
rrkumarshikhar wants to merge 1 commit into
Open
Conversation
|
🤖 Pull Request Artifacts (#30090577655) 🎉 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the configtree etcd import helper to derive the etcd endpoint from the environment and to accept more flexible endpoint formats, aligning the CLI’s etcd connectivity behavior with external configuration (e.g., environment variables).
Changes:
- Add
ETCD_ENDPOINTfallback when no explicit endpoint is provided. - Add endpoint normalization for comma-separated endpoint lists.
- Introduce basic
host[:port]parsing to derive host/port forEtcd3Client.
Comments suppressed due to low confidence (1)
riocli/configtree/etcd.py:56
import_in_etcdonly parsesendpointwhenport is None. If the caller passes a non-None port (e.g., the CLI option default 2379) and the endpoint is provided ashost:port, thehostpassed toEtcd3Clientstill contains the:portsuffix (leading to malformed URLs likehost:1234:2379). Consider always stripping any:portsuffix fromendpoint, and only using the parsed port when the caller didn't explicitly override it.
# Parse endpoint if port is not separately provided
if port is None:
endpoint, port = _parse_etcd_endpoint(endpoint)
cli = Etcd3Client(host=endpoint, port=port)
Comment on lines
+29
to
+35
| if ':' in endpoint_str: | ||
| host, port_str = endpoint_str.rsplit(':', 1) | ||
| try: | ||
| return host, int(port_str) | ||
| except ValueError: | ||
| return endpoint_str, 2379 | ||
| return endpoint_str, 2379 |
Comment on lines
+44
to
+46
| # Use environment variable if endpoint not provided | ||
| if endpoint is None: | ||
| endpoint = os.getenv("ETCD_ENDPOINT", "localhost") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.