From e95f845b41bcebdf04796f13d1c8328fdfbd3aa0 Mon Sep 17 00:00:00 2001 From: Harshad Khetpal Date: Thu, 20 Aug 2026 13:58:23 +0530 Subject: [PATCH 1/2] fix: remove stale local copy shadowing get_image_pull_backoff_container_statuses Co-Authored-By: Claude Fable 5 --- .../robusta_playbooks/image_pull_backoff_enricher.py | 12 ------------ .../job_restart_on_oomkilled_community.py | 4 ++-- src/robusta/api/__init__.py | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/playbooks/robusta_playbooks/image_pull_backoff_enricher.py b/playbooks/robusta_playbooks/image_pull_backoff_enricher.py index 54b006f03..8c8a79768 100755 --- a/playbooks/robusta_playbooks/image_pull_backoff_enricher.py +++ b/playbooks/robusta_playbooks/image_pull_backoff_enricher.py @@ -1,9 +1,5 @@ -import enum import logging -from enum import Flag -from typing import List -from hikaru.model.rel_1_26 import ContainerStatus, PodStatus from robusta.api import ( Finding, FindingSeverity, @@ -19,14 +15,6 @@ ) -def get_image_pull_backoff_container_statuses(status: PodStatus) -> List[ContainerStatus]: - return [ - container_status - for container_status in status.containerStatuses - if container_status.state.waiting is not None and container_status.state.waiting.reason == "ImagePullBackOff" - ] - - @action def image_pull_backoff_reporter(event: PodEvent, action_params: RateLimitParams): """ diff --git a/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py b/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py index 910c85e69..dee181cc3 100644 --- a/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py +++ b/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py @@ -41,7 +41,7 @@ def job_restart_on_oomkilled_community(event: JobEvent, params: IncreaseResource try: pod = get_job_latest_pod(job_event) - except: + except Exception: logging.error(f"get_job_pod was called on event without job: {event}") return @@ -54,7 +54,7 @@ def job_restart_on_oomkilled_community(event: JobEvent, params: IncreaseResource """ OOMKilled = "OOMKilled" for status in pod.status.containerStatuses: - if status.state.running == None: + if status.state.running is None: if status.state.terminated.reason == OOMKilled: oomkilled_containers.append(status.name) else: diff --git a/src/robusta/api/__init__.py b/src/robusta/api/__init__.py index 99bfe2b75..bd70c6b26 100644 --- a/src/robusta/api/__init__.py +++ b/src/robusta/api/__init__.py @@ -267,7 +267,6 @@ ReplicaSetAttributes, ReplicaSetChangeEvent, ReplicaSetEvent, - ResourceAttributes, ResourceLoader, ServiceAccountAttributes, ServiceAccountChangeEvent, From 045d4e3dd6f40e18cfd995e696abad09f77a726d Mon Sep 17 00:00:00 2001 From: Harshad Khetpal Date: Tue, 25 Aug 2026 19:50:24 +0530 Subject: [PATCH 2/2] fix: guard against missing pod in OOMKilled restart playbook get_job_latest_pod returns None when the job has no pods; pod.status would raise AttributeError. Addresses review feedback. Co-Authored-By: Claude Fable 5 Signed-off-by: Harshad Khetpal --- .../robusta_playbooks/job_restart_on_oomkilled_community.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py b/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py index dee181cc3..7f8fa6998 100644 --- a/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py +++ b/playbooks/robusta_playbooks/job_restart_on_oomkilled_community.py @@ -45,6 +45,10 @@ def job_restart_on_oomkilled_community(event: JobEvent, params: IncreaseResource logging.error(f"get_job_pod was called on event without job: {event}") return + if pod is None: + logging.error(f"no pod found for job event: {event}") + return + containers = [] oomkilled_containers = [] running_containers = []