Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAIN-1753 - patched pod conditions #295

Merged
merged 1 commit into from
Jun 20, 2024
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
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)
Loading