Skip to content

Get ln node host from pod name#809

Draft
Jhoyola wants to merge 1 commit into
bitcoin-dev-project:mainfrom
Jhoyola:normalize-ln-node-host-command
Draft

Get ln node host from pod name#809
Jhoyola wants to merge 1 commit into
bitcoin-dev-project:mainfrom
Jhoyola:normalize-ln-node-host-command

Conversation

@Jhoyola
Copy link
Copy Markdown
Contributor

@Jhoyola Jhoyola commented Jun 5, 2026

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.

Copilot AI review requested due to automatic review settings June 5, 2026 08:31
Copy link
Copy Markdown

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

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 thread src/warnet/ln.py
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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@Jhoyola Jhoyola marked this pull request as draft June 5, 2026 08:43
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.

2 participants