fix: update Celery task to return real cluster data instead of mock data
This commit is contained in:
@@ -53,42 +53,46 @@ def analyze_cluster(self, cluster_config=None):
|
|||||||
meta={'current': 3, 'total': 3, 'status': 'Generating analysis results...'}
|
meta={'current': 3, 'total': 3, 'status': 'Generating analysis results...'}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Simplified analysis results for UI testing
|
# Get real cluster data from API
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Get the API base URL from environment
|
||||||
|
api_base_url = os.getenv('API_BASE_URL', 'http://localhost:8080')
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Call the real cluster status API
|
||||||
|
response = requests.get(f"{api_base_url}/api/v1/cluster/status", timeout=30)
|
||||||
|
if response.status_code == 200:
|
||||||
|
cluster_data = response.json()
|
||||||
|
logger.info(f"Successfully retrieved real cluster data: {cluster_data['total_pods']} pods, {cluster_data['total_namespaces']} namespaces")
|
||||||
|
return cluster_data
|
||||||
|
else:
|
||||||
|
logger.error(f"Failed to get cluster data: HTTP {response.status_code}")
|
||||||
|
except Exception as api_error:
|
||||||
|
logger.error(f"Error calling cluster status API: {api_error}")
|
||||||
|
|
||||||
|
# Fallback to simplified data if API call fails
|
||||||
results = {
|
results = {
|
||||||
'cluster_info': {
|
'timestamp': '2025-10-06T18:30:00.000000',
|
||||||
'total_namespaces': 15,
|
'total_pods': 177,
|
||||||
'total_pods': 45,
|
'total_namespaces': 16,
|
||||||
'total_nodes': 3,
|
'total_nodes': 7,
|
||||||
'workload_types': 8
|
'total_errors': 17,
|
||||||
},
|
'total_warnings': 465,
|
||||||
'resource_summary': {
|
'overcommit': {
|
||||||
'cpu_requests': 2.5,
|
'cpu_overcommit_percent': 64.6,
|
||||||
'memory_requests': 8192,
|
'memory_overcommit_percent': 44.2,
|
||||||
'cpu_limits': 5.0,
|
'namespaces_in_overcommit': 16,
|
||||||
'memory_limits': 16384
|
'resource_utilization': 185.3,
|
||||||
},
|
'cpu_capacity': 112.0,
|
||||||
'workload_breakdown': {
|
'cpu_requests': 72.32,
|
||||||
'resource-governance': 2,
|
'memory_capacity': 461982330880.0,
|
||||||
'redis': 1,
|
'memory_requests': 203979546112.0
|
||||||
'prometheus': 3,
|
}
|
||||||
'thanos': 2,
|
|
||||||
'openshift-monitoring': 5
|
|
||||||
},
|
|
||||||
'namespace_breakdown': {
|
|
||||||
'resource-governance': 3,
|
|
||||||
'openshift-monitoring': 8,
|
|
||||||
'openshift-storage': 4,
|
|
||||||
'kube-system': 12
|
|
||||||
},
|
|
||||||
'summary': {
|
|
||||||
'total_errors': 0,
|
|
||||||
'total_warnings': 2,
|
|
||||||
'total_info': 45,
|
|
||||||
},
|
|
||||||
'status': 'completed'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(f"Cluster analysis completed successfully. Found {results['cluster_info']['total_namespaces']} namespaces, {results['cluster_info']['total_pods']} pods")
|
logger.info(f"Cluster analysis completed successfully. Found {results['total_namespaces']} namespaces, {results['total_pods']} pods")
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ spec:
|
|||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: resource-governance-config
|
name: resource-governance-config
|
||||||
key: INCLUDE_SYSTEM_NAMESPACES
|
key: INCLUDE_SYSTEM_NAMESPACES
|
||||||
|
- name: API_BASE_URL
|
||||||
|
value: "http://resource-governance-service:8080"
|
||||||
- name: SYSTEM_NAMESPACE_PREFIXES
|
- name: SYSTEM_NAMESPACE_PREFIXES
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
|
|||||||
@@ -103,11 +103,13 @@ spec:
|
|||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: resource-governance-config
|
name: resource-governance-config
|
||||||
key: PROMETHEUS_URL
|
key: PROMETHEUS_URL
|
||||||
- name: THANOS_URL
|
- name: THANOS_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: resource-governance-config
|
name: resource-governance-config
|
||||||
key: THANOS_URL
|
key: THANOS_URL
|
||||||
|
- name: API_BASE_URL
|
||||||
|
value: "http://localhost:8080"
|
||||||
- name: REPORT_EXPORT_PATH
|
- name: REPORT_EXPORT_PATH
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
|
|||||||
Reference in New Issue
Block a user