Get ln node host from pod name#809
Draft
Jhoyola wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR changes Lightning node host resolution to derive a DNS name from Kubernetes pod metadata instead of calling the node RPC and parsing getinfo.
Changes:
- Removes
_rpc(..., "getinfo")usage and JSON parsing for CLN/LND. - Returns a host string based on
<pod-name>.<namespace>.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
72
to
+77
| def _host(pod_name: str): | ||
| info = _rpc(pod_name, "getinfo") | ||
| pod = get_pod(pod_name) | ||
| if "cln" in pod.metadata.labels["app.kubernetes.io/name"]: | ||
| return json.loads(info)["alias"] | ||
| else: | ||
| uris = json.loads(info)["uris"] | ||
| if uris and len(uris) >= 0: | ||
| return uris[0].split("@")[1] | ||
| else: | ||
| return "" | ||
|
|
||
| # pod name (lnd.fullname / cln.fullname) matches the configs | ||
| # 'announce-addr' and 'externalhosts' in configmaps | ||
| return pod.metadata.name + "." + pod.metadata.namespace |
Contributor
Author
There was a problem hiding this comment.
Yeah yeah, I know and explained it: helm set exactly same value for the pod and the service, so by using pod name it's also service name and resolves correctly. Also for CLN it's the exact same string that was returned earlier.
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.
TODO still need to edit the ln_init to also use host name in original p2p, since peer connection is lost because the ip changes
My problem is that accross restarts the LND uris (ip:s) are not stable and since I use the address given by the host command (at the start of the network so not the current) in my app, it often loses connection on restart.
Inconsistently LND included the p2p port (9735) in the return value, now it's not returned.
This normalizes the host command to give the pod dns name.
Also, using "alias" for host name for CLN didn't really make sense. It's not the alias that is used in the connection. In reality it's the kube service name (service.yaml). These all work since for each
"lnd.fullname"or"cln.fullname"is used. The actual service name is a bit more cumbersome to get so I think the best is to just use the pod name.Tested in docker desktop cluster with CLN and LND.