Fix: Translate all remaining Portuguese text to English in routes, services and frontend
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Rotas da API
|
API Routes
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
@@ -37,7 +37,7 @@ async def get_cluster_status(
|
|||||||
k8s_client=Depends(get_k8s_client),
|
k8s_client=Depends(get_k8s_client),
|
||||||
prometheus_client=Depends(get_prometheus_client)
|
prometheus_client=Depends(get_prometheus_client)
|
||||||
):
|
):
|
||||||
"""Obter status geral do cluster"""
|
"""Get overall cluster status"""
|
||||||
try:
|
try:
|
||||||
# Coletar dados básicos
|
# Coletar dados básicos
|
||||||
pods = await k8s_client.get_all_pods()
|
pods = await k8s_client.get_all_pods()
|
||||||
@@ -52,7 +52,7 @@ async def get_cluster_status(
|
|||||||
# Obter informações de overcommit
|
# Obter informações de overcommit
|
||||||
overcommit_info = await prometheus_client.get_cluster_overcommit()
|
overcommit_info = await prometheus_client.get_cluster_overcommit()
|
||||||
|
|
||||||
# Obter recomendações VPA
|
# Get VPA recommendations
|
||||||
vpa_recommendations = await k8s_client.get_vpa_recommendations()
|
vpa_recommendations = await k8s_client.get_vpa_recommendations()
|
||||||
|
|
||||||
# Generate report
|
# Generate report
|
||||||
@@ -76,7 +76,7 @@ async def get_namespace_status(
|
|||||||
k8s_client=Depends(get_k8s_client),
|
k8s_client=Depends(get_k8s_client),
|
||||||
prometheus_client=Depends(get_prometheus_client)
|
prometheus_client=Depends(get_prometheus_client)
|
||||||
):
|
):
|
||||||
"""Obter status de um namespace específico"""
|
"""Get status of a specific namespace"""
|
||||||
try:
|
try:
|
||||||
# Coletar dados do namespace
|
# Coletar dados do namespace
|
||||||
namespace_resources = await k8s_client.get_namespace_resources(namespace)
|
namespace_resources = await k8s_client.get_namespace_resources(namespace)
|
||||||
@@ -109,7 +109,7 @@ async def get_pods(
|
|||||||
namespace: Optional[str] = None,
|
namespace: Optional[str] = None,
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Listar pods com informações de recursos"""
|
"""List pods with resource information"""
|
||||||
try:
|
try:
|
||||||
if namespace:
|
if namespace:
|
||||||
namespace_resources = await k8s_client.get_namespace_resources(namespace)
|
namespace_resources = await k8s_client.get_namespace_resources(namespace)
|
||||||
@@ -129,7 +129,7 @@ async def get_validations(
|
|||||||
page_size: int = 50,
|
page_size: int = 50,
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Listar validações de recursos com paginação"""
|
"""List resource validations with pagination"""
|
||||||
try:
|
try:
|
||||||
# Coletar pods
|
# Coletar pods
|
||||||
if namespace:
|
if namespace:
|
||||||
@@ -178,7 +178,7 @@ async def get_validations_by_namespace(
|
|||||||
include_system_namespaces: bool = False,
|
include_system_namespaces: bool = False,
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Listar validações agrupadas por namespace com paginação"""
|
"""List validations grouped by namespace with pagination"""
|
||||||
try:
|
try:
|
||||||
# Coletar todos os pods com filtro de namespaces do sistema
|
# Coletar todos os pods com filtro de namespaces do sistema
|
||||||
pods = await k8s_client.get_all_pods(include_system_namespaces=include_system_namespaces)
|
pods = await k8s_client.get_all_pods(include_system_namespaces=include_system_namespaces)
|
||||||
@@ -196,7 +196,7 @@ async def get_validations_by_namespace(
|
|||||||
"severity_breakdown": {"error": 0, "warning": 0}
|
"severity_breakdown": {"error": 0, "warning": 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Agrupar validações por pod
|
# Group validations by pod
|
||||||
if pod.name not in namespace_validations[pod.namespace]["pods"]:
|
if pod.name not in namespace_validations[pod.namespace]["pods"]:
|
||||||
namespace_validations[pod.namespace]["pods"][pod.name] = {
|
namespace_validations[pod.namespace]["pods"][pod.name] = {
|
||||||
"pod_name": pod.name,
|
"pod_name": pod.name,
|
||||||
@@ -214,7 +214,7 @@ async def get_validations_by_namespace(
|
|||||||
for validation in pod_validations:
|
for validation in pod_validations:
|
||||||
namespace_validations[pod.namespace]["severity_breakdown"][validation.severity] += 1
|
namespace_validations[pod.namespace]["severity_breakdown"][validation.severity] += 1
|
||||||
|
|
||||||
# Converter para lista e ordenar por total de validações
|
# Convert to list and sort by total validations
|
||||||
namespace_list = list(namespace_validations.values())
|
namespace_list = list(namespace_validations.values())
|
||||||
namespace_list.sort(key=lambda x: x["total_validations"], reverse=True)
|
namespace_list.sort(key=lambda x: x["total_validations"], reverse=True)
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ async def get_vpa_recommendations(
|
|||||||
namespace: Optional[str] = None,
|
namespace: Optional[str] = None,
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Obter recomendações do VPA"""
|
"""Get VPA recommendations"""
|
||||||
try:
|
try:
|
||||||
recommendations = await k8s_client.get_vpa_recommendations()
|
recommendations = await k8s_client.get_vpa_recommendations()
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ async def apply_recommendation(
|
|||||||
recommendation: ApplyRecommendationRequest,
|
recommendation: ApplyRecommendationRequest,
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Aplicar recomendação de recursos"""
|
"""Apply resource recommendation"""
|
||||||
try:
|
try:
|
||||||
# TODO: Implementar aplicação de recomendações
|
# TODO: Implementar aplicação de recomendações
|
||||||
# Por enquanto, apenas simular
|
# Por enquanto, apenas simular
|
||||||
@@ -374,7 +374,7 @@ async def get_historical_validations(
|
|||||||
time_range: str = "24h",
|
time_range: str = "24h",
|
||||||
k8s_client=Depends(get_k8s_client)
|
k8s_client=Depends(get_k8s_client)
|
||||||
):
|
):
|
||||||
"""Obter validações com análise histórica do Prometheus"""
|
"""Get validations with historical analysis from Prometheus"""
|
||||||
try:
|
try:
|
||||||
validation_service = ValidationService()
|
validation_service = ValidationService()
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@ async def get_historical_validations(
|
|||||||
async def get_cluster_historical_summary(
|
async def get_cluster_historical_summary(
|
||||||
time_range: str = "24h"
|
time_range: str = "24h"
|
||||||
):
|
):
|
||||||
"""Obter resumo histórico do cluster"""
|
"""Get cluster historical summary"""
|
||||||
try:
|
try:
|
||||||
historical_service = HistoricalAnalysisService()
|
historical_service = HistoricalAnalysisService()
|
||||||
summary = await historical_service.get_cluster_historical_summary(time_range)
|
summary = await historical_service.get_cluster_historical_summary(time_range)
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class ReportService:
|
|||||||
problems[problem_type] = []
|
problems[problem_type] = []
|
||||||
problems[problem_type].append(validation)
|
problems[problem_type].append(validation)
|
||||||
|
|
||||||
# Generate recommendations específicas
|
# Generate specific recommendations
|
||||||
if "missing_requests" in problems:
|
if "missing_requests" in problems:
|
||||||
count = len(problems["missing_requests"])
|
count = len(problems["missing_requests"])
|
||||||
recommendations.append(
|
recommendations.append(
|
||||||
@@ -148,12 +148,12 @@ class ReportService:
|
|||||||
if "invalid_ratio" in problems:
|
if "invalid_ratio" in problems:
|
||||||
count = len(problems["invalid_ratio"])
|
count = len(problems["invalid_ratio"])
|
||||||
recommendations.append(
|
recommendations.append(
|
||||||
f"Ajustar ratio limit:request para {count} containers"
|
f"Adjust limit:request ratio for {count} containers"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "overcommit" in problems:
|
if "overcommit" in problems:
|
||||||
recommendations.append(
|
recommendations.append(
|
||||||
"Resolver overcommit de recursos no namespace"
|
"Resolve resource overcommit in namespace"
|
||||||
)
|
)
|
||||||
|
|
||||||
return recommendations
|
return recommendations
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Serviço de validação de recursos seguindo best practices Red Hat
|
Resource validation service following Red Hat best practices
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Dict, Any
|
from typing import List, Dict, Any
|
||||||
@@ -13,7 +13,7 @@ from app.services.historical_analysis import HistoricalAnalysisService
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ValidationService:
|
class ValidationService:
|
||||||
"""Serviço para validação de recursos"""
|
"""Service for resource validation"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cpu_ratio = settings.cpu_limit_ratio
|
self.cpu_ratio = settings.cpu_limit_ratio
|
||||||
@@ -23,7 +23,7 @@ class ValidationService:
|
|||||||
self.historical_analysis = HistoricalAnalysisService()
|
self.historical_analysis = HistoricalAnalysisService()
|
||||||
|
|
||||||
def validate_pod_resources(self, pod: PodResource) -> List[ResourceValidation]:
|
def validate_pod_resources(self, pod: PodResource) -> List[ResourceValidation]:
|
||||||
"""Validar recursos de um pod"""
|
"""Validate pod resources"""
|
||||||
validations = []
|
validations = []
|
||||||
|
|
||||||
for container in pod.containers:
|
for container in pod.containers:
|
||||||
@@ -39,7 +39,7 @@ class ValidationService:
|
|||||||
pod: PodResource,
|
pod: PodResource,
|
||||||
time_range: str = '24h'
|
time_range: str = '24h'
|
||||||
) -> List[ResourceValidation]:
|
) -> List[ResourceValidation]:
|
||||||
"""Validar recursos de um pod incluindo análise histórica"""
|
"""Validate pod resources including historical analysis"""
|
||||||
# Validações estáticas
|
# Validações estáticas
|
||||||
static_validations = self.validate_pod_resources(pod)
|
static_validations = self.validate_pod_resources(pod)
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class ValidationService:
|
|||||||
namespace: str,
|
namespace: str,
|
||||||
container: Dict[str, Any]
|
container: Dict[str, Any]
|
||||||
) -> List[ResourceValidation]:
|
) -> List[ResourceValidation]:
|
||||||
"""Validar recursos de um container"""
|
"""Validate container resources"""
|
||||||
validations = []
|
validations = []
|
||||||
resources = container.get("resources", {})
|
resources = container.get("resources", {})
|
||||||
requests = resources.get("requests", {})
|
requests = resources.get("requests", {})
|
||||||
@@ -90,7 +90,7 @@ class ValidationService:
|
|||||||
recommendation="Define limits to avoid excessive resource consumption"
|
recommendation="Define limits to avoid excessive resource consumption"
|
||||||
))
|
))
|
||||||
|
|
||||||
# 3. Validar ratio limit:request
|
# 3. Validate limit:request ratio
|
||||||
if requests and limits:
|
if requests and limits:
|
||||||
cpu_validation = self._validate_cpu_ratio(
|
cpu_validation = self._validate_cpu_ratio(
|
||||||
pod_name, namespace, container["name"], requests, limits
|
pod_name, namespace, container["name"], requests, limits
|
||||||
@@ -104,7 +104,7 @@ class ValidationService:
|
|||||||
if memory_validation:
|
if memory_validation:
|
||||||
validations.append(memory_validation)
|
validations.append(memory_validation)
|
||||||
|
|
||||||
# 4. Validar valores mínimos
|
# 4. Validate minimum values
|
||||||
if requests:
|
if requests:
|
||||||
min_validation = self._validate_minimum_values(
|
min_validation = self._validate_minimum_values(
|
||||||
pod_name, namespace, container["name"], requests
|
pod_name, namespace, container["name"], requests
|
||||||
@@ -121,7 +121,7 @@ class ValidationService:
|
|||||||
requests: Dict[str, str],
|
requests: Dict[str, str],
|
||||||
limits: Dict[str, str]
|
limits: Dict[str, str]
|
||||||
) -> ResourceValidation:
|
) -> ResourceValidation:
|
||||||
"""Validar ratio CPU limit:request"""
|
"""Validate CPU limit:request ratio"""
|
||||||
if "cpu" not in requests or "cpu" not in limits:
|
if "cpu" not in requests or "cpu" not in limits:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class ValidationService:
|
|||||||
requests: Dict[str, str],
|
requests: Dict[str, str],
|
||||||
limits: Dict[str, str]
|
limits: Dict[str, str]
|
||||||
) -> ResourceValidation:
|
) -> ResourceValidation:
|
||||||
"""Validar ratio memória limit:request"""
|
"""Validate memory limit:request ratio"""
|
||||||
if "memory" not in requests or "memory" not in limits:
|
if "memory" not in requests or "memory" not in limits:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ class ValidationService:
|
|||||||
container_name: str,
|
container_name: str,
|
||||||
requests: Dict[str, str]
|
requests: Dict[str, str]
|
||||||
) -> List[ResourceValidation]:
|
) -> List[ResourceValidation]:
|
||||||
"""Validar valores mínimos de requests"""
|
"""Validate minimum request values"""
|
||||||
validations = []
|
validations = []
|
||||||
|
|
||||||
# Validar CPU mínima
|
# Validar CPU mínima
|
||||||
@@ -286,7 +286,7 @@ class ValidationService:
|
|||||||
namespace_resources: NamespaceResources,
|
namespace_resources: NamespaceResources,
|
||||||
node_capacity: Dict[str, str]
|
node_capacity: Dict[str, str]
|
||||||
) -> List[ResourceValidation]:
|
) -> List[ResourceValidation]:
|
||||||
"""Validar overcommit em um namespace"""
|
"""Validate overcommit in a namespace"""
|
||||||
validations = []
|
validations = []
|
||||||
|
|
||||||
# Calcular total de requests do namespace
|
# Calcular total de requests do namespace
|
||||||
@@ -328,7 +328,7 @@ class ValidationService:
|
|||||||
return validations
|
return validations
|
||||||
|
|
||||||
def generate_recommendations(self, validations: List[ResourceValidation]) -> List[str]:
|
def generate_recommendations(self, validations: List[ResourceValidation]) -> List[str]:
|
||||||
"""Gerar recomendações baseadas nas validações"""
|
"""Generate recommendations based on validations"""
|
||||||
recommendations = []
|
recommendations = []
|
||||||
|
|
||||||
# Agrupar validações por tipo
|
# Agrupar validações por tipo
|
||||||
|
|||||||
@@ -741,7 +741,7 @@
|
|||||||
updateStats(data);
|
updateStats(data);
|
||||||
showSuccess('Cluster status loaded successfully. Loading analysis...');
|
showSuccess('Cluster status loaded successfully. Loading analysis...');
|
||||||
|
|
||||||
// Carregar automaticamente as validações após o scan inicial
|
// Automatically load validations after initial scan
|
||||||
await loadValidationsByNamespace();
|
await loadValidationsByNamespace();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1029,9 +1029,9 @@
|
|||||||
let html = '';
|
let html = '';
|
||||||
|
|
||||||
// Botão anterior
|
// Botão anterior
|
||||||
html += `<button onclick="loadPage(${pagination.page - 1})" ${pagination.page <= 1 ? 'disabled' : ''}>Anterior</button>`;
|
html += `<button onclick="loadPage(${pagination.page - 1})" ${pagination.page <= 1 ? 'disabled' : ''}>Previous</button>`;
|
||||||
|
|
||||||
// Páginas
|
// Pages
|
||||||
const startPage = Math.max(1, pagination.page - 2);
|
const startPage = Math.max(1, pagination.page - 2);
|
||||||
const endPage = Math.min(pagination.total_pages, pagination.page + 2);
|
const endPage = Math.min(pagination.total_pages, pagination.page + 2);
|
||||||
|
|
||||||
@@ -1055,11 +1055,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Botão próximo
|
// Botão próximo
|
||||||
html += `<button onclick="loadPage(${pagination.page + 1})" ${pagination.page >= pagination.total_pages ? 'disabled' : ''}>Próximo</button>`;
|
html += `<button onclick="loadPage(${pagination.page + 1})" ${pagination.page >= pagination.total_pages ? 'disabled' : ''}>Next</button>`;
|
||||||
|
|
||||||
// Informações da paginação
|
// Informações da paginação
|
||||||
html += `<div class="pagination-info">
|
html += `<div class="pagination-info">
|
||||||
Página ${pagination.page} de ${pagination.total_pages}
|
Page ${pagination.page} of ${pagination.total_pages}
|
||||||
(${pagination.total} namespaces)
|
(${pagination.total} namespaces)
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
@@ -1151,7 +1151,7 @@
|
|||||||
displayHistoricalSummary(summaryData.summary);
|
displayHistoricalSummary(summaryData.summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carregar validações históricas
|
// Load historical validations
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
time_range: timeRange
|
time_range: timeRange
|
||||||
});
|
});
|
||||||
@@ -1180,7 +1180,7 @@
|
|||||||
const container = document.getElementById('historicalSummary');
|
const container = document.getElementById('historicalSummary');
|
||||||
|
|
||||||
if (!summary || Object.keys(summary).length === 0) {
|
if (!summary || Object.keys(summary).length === 0) {
|
||||||
container.innerHTML = '<p>Não foi possível obter dados históricos do Prometheus.</p>';
|
container.innerHTML = '<p>Unable to get historical data from Prometheus.</p>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,7 +1266,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="validation-message">${validation.message}</div>
|
<div class="validation-message">${validation.message}</div>
|
||||||
<div class="validation-recommendation">
|
<div class="validation-recommendation">
|
||||||
<strong>Recomendação:</strong> ${validation.recommendation}
|
<strong>Recommendation:</strong> ${validation.recommendation}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`).join('')}
|
`).join('')}
|
||||||
|
|||||||
Reference in New Issue
Block a user