Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 6bf5afd

Browse files
committed
Use alternative endpoint on client side
1 parent 7867053 commit 6bf5afd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • packages/jumpstarter/jumpstarter/client

packages/jumpstarter/jumpstarter/client/client.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from jumpstarter.client import DriverClient
1212
from jumpstarter.common.importlib import import_class
13+
from jumpstarter.common.grpc import aio_secure_channel
1314

1415

1516
@asynccontextmanager
@@ -26,6 +27,7 @@ async def client_from_channel(
2627
stack: ExitStack,
2728
allow: list[str],
2829
unsafe: bool,
30+
use_alternative_endpoints: bool = True,
2931
) -> DriverClient:
3032
topo = defaultdict(list)
3133
last_seen = {}
@@ -34,6 +36,25 @@ async def client_from_channel(
3436

3537
response = await jumpstarter_pb2_grpc.ExporterServiceStub(channel).GetReport(empty_pb2.Empty())
3638

39+
if use_alternative_endpoints:
40+
for endpoint in response.alternative_endpoints:
41+
if endpoint.certificate:
42+
attempted_channel = aio_secure_channel(
43+
endpoint.endpoint,
44+
grpc.ssl_channel_credentials(root_certificates=endpoint.certificate.encode()),
45+
) # TODO: set token
46+
try:
47+
response = await jumpstarter_pb2_grpc.ExporterServiceStub(attempted_channel).GetReport(
48+
empty_pb2.Empty()
49+
)
50+
except Exception:
51+
pass # TODO: log failed attempt
52+
else:
53+
channel = attempted_channel
54+
break
55+
else:
56+
continue
57+
3758
for index, report in enumerate(response.reports):
3859
topo[index] = []
3960

0 commit comments

Comments
 (0)