Skip to content

Commit

Permalink
MAIN-1753 - patched pod conditions (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-Robusta authored Jun 20, 2024
1 parent 99ce16c commit c400fc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from robusta_krr.utils.intro import load_intro_message
from robusta_krr.utils.progress_bar import ProgressBar
from robusta_krr.utils.version import get_version, load_latest_version
from robusta_krr.utils.patch import create_monkey_patches

logger = logging.getLogger("krr")

Expand Down Expand Up @@ -312,7 +313,6 @@ async def _collect_result(self) -> Result:
async def run(self) -> int:
"""Run the Runner. The return value is the exit code of the program."""
await self._greet()

try:
settings.load_kubeconfig()
except Exception as e:
Expand All @@ -321,6 +321,7 @@ async def run(self) -> int:
return 1 # Exit with error

try:
create_monkey_patches()
# eks has a lower step limit than other types of prometheus, it will throw an error
step_count = self._strategy.settings.history_duration * 60 / self._strategy.settings.timeframe_duration
if settings.eks_managed_prom and step_count > 11000:
Expand Down
15 changes: 15 additions & 0 deletions robusta_krr/utils/patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging

from kubernetes.client.models.v1_pod_failure_policy_rule import V1PodFailurePolicyRule

def create_monkey_patches():
"""
The python kubernetes client will throw exceptions for specific fields that were not allowed to be None on older versions of kubernetes.
"""
logger = logging.getLogger("krr")
logger.debug("Creating kubernetes python cli monkey patches")

def patched_setter_pod_failure_policy(self, on_pod_conditions):
self._on_pod_conditions = on_pod_conditions

V1PodFailurePolicyRule.on_pod_conditions = V1PodFailurePolicyRule.on_pod_conditions.setter(patched_setter_pod_failure_policy)

0 comments on commit c400fc8

Please sign in to comment.