feat(agent): unify service statuses across monitor impls
This commit is contained in:
@@ -44,7 +44,23 @@ func (self *KubesMonitor) CheckServices(ctx context.Context) ([]models.Service,
|
||||
return lo.Map(pods.Items, func(item corev1.Pod, _ int) models.Service {
|
||||
return models.Service{
|
||||
Name: item.Name,
|
||||
Status: string(item.Status.Phase), // TODO: map to standartized states enum
|
||||
Status: mapPodPhase(item.Status.Phase),
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
// mapPodPhase maps K8s pod phases to unified ServiceStatus.
|
||||
func mapPodPhase(phase corev1.PodPhase) models.ServiceStatus {
|
||||
switch phase {
|
||||
case corev1.PodRunning:
|
||||
return models.StatusRunning
|
||||
case corev1.PodSucceeded:
|
||||
return models.StatusStopped
|
||||
case corev1.PodFailed:
|
||||
return models.StatusStopped
|
||||
case corev1.PodPending:
|
||||
return models.StatusPending
|
||||
default:
|
||||
return models.StatusUnknown
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user