Skip to content

Commit d955dd9

Browse files
committed
making coderabbit happy
1 parent b79d7fe commit d955dd9

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

robusta_krr/core/integrations/kubernetes/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from robusta_krr.core.models.config import settings
2222
from robusta_krr.core.models.objects import HPAData, K8sObjectData, KindLiteral, PodData
2323
from robusta_krr.core.models.result import ResourceAllocations
24+
from robusta_krr.core.models.result import ResourceType
2425
from robusta_krr.utils.object_like_dict import ObjectLikeDict
2526

2627
from . import config_patch as _
@@ -217,10 +218,18 @@ def __build_scannable_object(
217218

218219
# Special handling for CNPGCluster
219220
if kind == "CNPGCluster":
220-
resources = getattr(item.spec, "resources", None) or item.get("spec", {}).get("resources", {})
221+
resources = getattr(item.spec, "resources", None) or item.get("spec", {}).get("resources", {}) or {}
222+
req = resources.get("requests", {}) or {}
223+
lim = resources.get("limits", {}) or {}
221224
allocations = ResourceAllocations(
222-
requests=resources.get("requests", {}),
223-
limits=resources.get("limits", {}),
225+
requests={
226+
ResourceType.CPU: req.get("cpu"),
227+
ResourceType.Memory: req.get("memory"),
228+
},
229+
limits={
230+
ResourceType.CPU: lim.get("cpu"),
231+
ResourceType.Memory: lim.get("memory"),
232+
},
224233
)
225234
container_name = "postgres"
226235
else:

robusta_krr/formatters/csv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def _format_total_diff(item: ResourceScan, resource: ResourceType, pods_current:
4444
selector = "requests"
4545
allocated = getattr(item.object.allocations, selector).get(resource, None)
4646
recommended = getattr(item.recommended, selector).get(resource, None)
47+
if recommended is None:
48+
return ""
4749

4850
return format_diff(allocated, recommended, selector, pods_current)
4951

0 commit comments

Comments
 (0)