Skip to content

Commit

Permalink
Merge branch 'main' into fallback-get-pods
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed Oct 20, 2023
2 parents 9a6a483 + 1dbe77a commit 0399758
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from robusta_krr.core.models.objects import HPAData, K8sObjectData, KindLiteral, PodData
from robusta_krr.core.models.result import ResourceAllocations

from . import config_patch as _
from .rollout import RolloutAppsV1Api

logger = logging.getLogger("krr")
Expand Down
37 changes: 37 additions & 0 deletions robusta_krr/core/integrations/kubernetes/config_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NOTE: This is a workaround for the issue described here:
# https://github.com/kubernetes-client/python/pull/1863

from __future__ import annotations

from kubernetes.client import configuration
from kubernetes.config import kube_config


class KubeConfigLoader(kube_config.KubeConfigLoader):
def _load_cluster_info(self):
super()._load_cluster_info()

if "proxy-url" in self._cluster:
self.proxy = self._cluster["proxy-url"]

def _set_config(self, client_configuration: Configuration):
super()._set_config(client_configuration)

key = "proxy"
if key in self.__dict__:
setattr(client_configuration, key, getattr(self, key))


class Configuration(configuration.Configuration):
def __init__(
self,
proxy: str | None = None,
**kwargs,
):
super().__init__(**kwargs)

self.proxy = proxy


configuration.Configuration = Configuration
kube_config.KubeConfigLoader = KubeConfigLoader
File renamed without changes.
2 changes: 1 addition & 1 deletion robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def _calculate_object_recommendations(self, object: K8sObjectData) -> RunR
prometheus_loader = self._get_prometheus_loader(object.cluster)

if prometheus_loader is None:
return {resource: ResourceRecommendation.undefined() for resource in ResourceType}
return {resource: ResourceRecommendation.undefined("Prometheus not found") for resource in ResourceType}

object.pods = await prometheus_loader.load_pods(object, self._strategy.settings.history_timedelta)
if object.pods == []:
Expand Down

0 comments on commit 0399758

Please sign in to comment.