mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
feat: add warning events count next to the status badge (#828)
This commit is contained in:
parent
f4df51884c
commit
1332f718ae
18 changed files with 120 additions and 37 deletions
|
@ -351,6 +351,34 @@ func (kcl *KubeClient) DeleteNamespace(namespaceName string) (*corev1.Namespace,
|
|||
return namespace, nil
|
||||
}
|
||||
|
||||
// CombineNamespacesWithUnhealthyEvents combines namespaces with unhealthy events across all namespaces
|
||||
func (kcl *KubeClient) CombineNamespacesWithUnhealthyEvents(namespaces map[string]portainer.K8sNamespaceInfo) (map[string]portainer.K8sNamespaceInfo, error) {
|
||||
allEvents, err := kcl.GetEvents("", "")
|
||||
if err != nil && !k8serrors.IsNotFound(err) {
|
||||
log.Error().
|
||||
Str("context", "CombineNamespacesWithUnhealthyEvents").
|
||||
Err(err).
|
||||
Msg("unable to retrieve unhealthy events from the Kubernetes for an admin user")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unhealthyEventCounts := make(map[string]int)
|
||||
for _, event := range allEvents {
|
||||
if event.Type == "Warning" {
|
||||
unhealthyEventCounts[event.Namespace]++
|
||||
}
|
||||
}
|
||||
|
||||
for namespaceName, namespace := range namespaces {
|
||||
if count, exists := unhealthyEventCounts[namespaceName]; exists {
|
||||
namespace.UnhealthyEventCount = count
|
||||
namespaces[namespaceName] = namespace
|
||||
}
|
||||
}
|
||||
|
||||
return namespaces, nil
|
||||
}
|
||||
|
||||
// CombineNamespacesWithResourceQuotas combines namespaces with resource quotas where matching is based on "portainer-rq-"+namespace.Name
|
||||
func (kcl *KubeClient) CombineNamespacesWithResourceQuotas(namespaces map[string]portainer.K8sNamespaceInfo, w http.ResponseWriter) *httperror.HandlerError {
|
||||
resourceQuotas, err := kcl.GetResourceQuotas("")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue