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

added pod count and resources to data #1477

Merged
merged 3 commits into from
Jul 24, 2024
Merged
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
9 changes: 9 additions & 0 deletions playbooks/robusta_playbooks/krr.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class KRRObject(BaseModel):
kind: str
allocations: Dict[str, Dict[str, Optional[float]]]
warnings: List[str] = []
current_pod_count: Optional[int]

def __init__(self, **data):
pods = data.pop('pods', [])
super().__init__(**data)
self.current_pod_count = len([pod for pod in pods if not pod.get('deleted', False)])


class KRRRecommendedInfo(BaseModel):
Expand Down Expand Up @@ -98,6 +104,7 @@ class KRRResponse(BaseModel):
strategy: Optional[KRRStrategyData] = None # This field is not returned by KRR < v1.3.0
errors: List[Dict[str, Any]] = [] # This field is not returned by KRR < v1.7.1
config: Optional[Dict[str, Any]] = None # This field is not returned by KRR < v1.9.0
clusterSummary: Optional[Dict[str, Any]] = None # This field is not returned by KRR < v1.12.0


class KRRParams(PrometheusParams, PodRunningParams):
Expand Down Expand Up @@ -392,6 +399,7 @@ def update_state(state: ScanState) -> None:
metadata["description"] = krr_scan.description
metadata["errors"] = krr_scan.errors
metadata["config"] = krr_scan.config
metadata["cluster_summary"] = krr_scan.clusterSummary

scan_block = KRRScanReportBlock(
title="KRR scan",
Expand Down Expand Up @@ -430,6 +438,7 @@ def update_state(state: ScanState) -> None:
"description": krr_scan.description,
"strategy": krr_scan.strategy.dict() if krr_scan.strategy else None,
"warnings": scan.object.warnings,
"current_pod_count": scan.object.current_pod_count
}
for resource in krr_scan.resources
],
Expand Down
Loading