|
21 | 21 | from robusta_krr.core.models.config import settings |
22 | 22 | from robusta_krr.core.models.objects import HPAData, K8sObjectData, KindLiteral, PodData |
23 | 23 | from robusta_krr.core.models.result import ResourceAllocations |
| 24 | +from robusta_krr.core.models.result import ResourceType |
24 | 25 | from robusta_krr.utils.object_like_dict import ObjectLikeDict |
25 | 26 |
|
26 | 27 | from . import config_patch as _ |
@@ -217,10 +218,18 @@ def __build_scannable_object( |
217 | 218 |
|
218 | 219 | # Special handling for CNPGCluster |
219 | 220 | 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 {} |
221 | 224 | 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 | + }, |
224 | 233 | ) |
225 | 234 | container_name = "postgres" |
226 | 235 | else: |
|
0 commit comments