Skip to content

Commit

Permalink
fix: Prevent the occasional unhandled UnboundLocalError in agent st…
Browse files Browse the repository at this point in the history
…ats routine

- Skip measuring the stat for an agent registry item if it has not yet assigned container ID
  • Loading branch information
adrysn committed Jun 22, 2022
1 parent 96033aa commit 772bea7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/478.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip measuring the stat for an agent registry item if it has not yet assigned container ID to prevent the occasional unhandled `UnboundLocalError`.
3 changes: 2 additions & 1 deletion src/ai/backend/agent/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ async def collect_container_stat(
cid = info['container_id']
except KeyError:
log.warning('collect_container_stat(): no container for kernel {}', kid)
kernel_id_map[ContainerId(cid)] = kid
else:
kernel_id_map[ContainerId(cid)] = kid
unused_kernel_ids = set(self.kernel_metrics.keys()) - set(kernel_id_map.values())
for unused_kernel_id in unused_kernel_ids:
log.debug('removing kernel_metric for {}', unused_kernel_id)
Expand Down

0 comments on commit 772bea7

Please sign in to comment.