Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

fix: Type errors found with new etcd module #556

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/566.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix up newly found type errors for updating `common.etcd` using `etcetra`
7 changes: 4 additions & 3 deletions src/ai/backend/manager/api/etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ async def get_config(request: web.Request, params: Any) -> web.Response:
)
if params['prefix']:
# Flatten the returned ChainMap object for JSON serialization
value = dict(await root_ctx.shared_config.etcd.get_prefix_dict(params['key']))
tree_value = dict(await root_ctx.shared_config.etcd.get_prefix_dict(params['key']))
return web.json_response({'result': tree_value})
else:
value = await root_ctx.shared_config.etcd.get(params['key'])
return web.json_response({'result': value})
scalar_value = await root_ctx.shared_config.etcd.get(params['key'])
return web.json_response({'result': scalar_value})


@superadmin_required
Expand Down
5 changes: 2 additions & 3 deletions src/ai/backend/manager/api/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,10 @@ async def get_watcher_info(request: web.Request, agent_id: str) -> dict:
if token is None:
token = 'insecure'
agent_ip = await root_ctx.shared_config.etcd.get(f'nodes/agents/{agent_id}/ip')
watcher_port = await root_ctx.shared_config.etcd.get(
raw_watcher_port = await root_ctx.shared_config.etcd.get(
f'nodes/agents/{agent_id}/watcher_port',
)
if watcher_port is None:
watcher_port = 6009
watcher_port = 6099 if raw_watcher_port is None else int(raw_watcher_port)
# TODO: watcher scheme is assumed to be http
addr = yarl.URL(f'http://{agent_ip}:{watcher_port}')
return {
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/manager/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ async def stream_conn_tracker_gc(root_ctx: RootContext, app_ctx: PrivateContext)
try:
while True:
no_packet_timeout: timedelta = tx.TimeDuration().check(
await shared_config.etcd.get('config/idle/app-streaming-packet-timeout', '5m'),
await shared_config.etcd.get('config/idle/app-streaming-packet-timeout') or '5m',
)
async with app_ctx.conn_tracker_lock:
now = await redis.execute(redis_live, lambda r: r.time())
Expand Down