Skip to content

Commit 658ce42

Browse files
committed
scenario commander: save ln pod namespace and add domain to URI
1 parent 9e1b6ad commit 658ce42

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

resources/scenarios/commander.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
WARNET["tanks"].append(
9393
{
9494
"tank": pod.metadata.name,
95+
"namespace": pod.metadata.namespace,
9596
"chain": pod.metadata.labels["chain"],
9697
"rpc_host": pod.status.pod_ip,
9798
"rpc_port": int(pod.metadata.labels["RPCPort"]),
@@ -104,10 +105,13 @@
104105
if pod.metadata.labels["mission"] == "lightning":
105106
if "lnd" in pod.metadata.labels["app.kubernetes.io/name"]:
106107
lnnode = LND(
107-
pod.metadata.name, pod.status.pod_ip, pod.metadata.annotations["adminMacaroon"]
108+
pod.metadata.name,
109+
pod.metadata.namespace,
110+
pod.status.pod_ip,
111+
pod.metadata.annotations["adminMacaroon"],
108112
)
109113
if "cln" in pod.metadata.labels["app.kubernetes.io/name"]:
110-
lnnode = CLN(pod.metadata.name, pod.status.pod_ip)
114+
lnnode = CLN(pod.metadata.name, pod.metadata.namespace, pod.status.pod_ip)
111115
assert lnnode
112116
WARNET["lightning"].append(lnnode)
113117

resources/scenarios/ln_framework/ln.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ def to_lnd_chanpolicy(self, capacity):
101101

102102
class LNNode(ABC):
103103
@abstractmethod
104-
def __init__(self, pod_name, ip_address):
104+
def __init__(self, pod_name, pod_namespace, ip_address):
105105
self.name = pod_name
106+
self.namespace = pod_namespace
106107
self.ip_address = ip_address
107108
self.log = logging.getLogger(pod_name)
108109
handler = logging.StreamHandler()
@@ -152,16 +153,16 @@ def update(self, txid_hex: str, policy: dict, capacity: int) -> dict:
152153

153154

154155
class CLN(LNNode):
155-
def __init__(self, pod_name, ip_address):
156-
super().__init__(pod_name, ip_address)
156+
def __init__(self, pod_name, pod_namespace, ip_address):
157+
super().__init__(pod_name, pod_namespace, ip_address)
157158
self.conn = None
158159
self.headers = {}
159160
self.impl = "cln"
160161
self.reset_connection()
161162

162163
def reset_connection(self):
163164
self.conn = http.client.HTTPSConnection(
164-
host=self.name, port=3010, timeout=60, context=INSECURE_CONTEXT
165+
host=f"{self.name}.{self.namespace}", port=3010, timeout=60, context=INSECURE_CONTEXT
165166
)
166167

167168
def setRune(self, rune):
@@ -285,11 +286,9 @@ def update(self, txid_hex: str, policy: dict, capacity: int) -> dict:
285286

286287

287288
class LND(LNNode):
288-
def __init__(self, pod_name, ip_address, admin_macaroon_hex):
289-
super().__init__(pod_name, ip_address)
290-
self.conn = http.client.HTTPSConnection(
291-
host=pod_name, port=8080, timeout=5, context=INSECURE_CONTEXT
292-
)
289+
def __init__(self, pod_name, pod_namespace, ip_address, admin_macaroon_hex):
290+
super().__init__(pod_name, pod_namespace, ip_address)
291+
self.conn = None
293292
self.admin_macaroon_hex = admin_macaroon_hex
294293
self.headers = {
295294
"Grpc-Metadata-macaroon": admin_macaroon_hex,
@@ -299,7 +298,7 @@ def __init__(self, pod_name, ip_address, admin_macaroon_hex):
299298

300299
def reset_connection(self):
301300
self.conn = http.client.HTTPSConnection(
302-
host=self.name, port=8080, timeout=60, context=INSECURE_CONTEXT
301+
host=f"{self.name}.{self.namespace}", port=8080, timeout=60, context=INSECURE_CONTEXT
303302
)
304303

305304
def get(self, uri):

0 commit comments

Comments
 (0)