Skip to content

Commit

Permalink
skip and log invalid k8s watch events (#2099)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Zubenko <ivan.zubenko@angloamerican.com>
  • Loading branch information
zubenkoivan and Ivan Zubenko authored Jun 5, 2023
1 parent b908c8a commit c048fdb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platform_api/orchestrator/kube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,14 @@ async def _watch(
if response.status == 410:
raise ResourceGoneException
async for line in response.content:
payload = json.loads(line)
try:
payload = json.loads(line)
except ValueError:
logger.warning("received invalid watch event object: %s", line)
continue
if "type" not in payload or "object" not in payload:
logger.warning("received invalid watch event object: %s", line)
continue
if WatchEvent.is_error(payload):
self._check_status_payload(payload["object"])
if WatchBookmarkEvent.is_bookmark(payload):
Expand Down

0 comments on commit c048fdb

Please sign in to comment.