cleanup and refactor health service
All checks were successful
Gitea Docker Build Demo / Test (push) Successful in 1m2s
Gitea Docker Build Demo / Build_Image (push) Successful in 1m22s

This commit is contained in:
2025-10-07 11:13:15 +02:00
parent 60844be81b
commit d3682557b1
7 changed files with 42 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"net/http"
"time"
"git.uploadfilter24.eu/covidnetes/canada-kaktus/internal"
@@ -20,11 +21,13 @@ func main() {
}).Fatal(fmt.Sprintf("Error generating Config: %s", err.Error()))
}
hs := internal.NewHealthServer()
go func() {
log.WithFields(log.Fields{
"Caller": "Main",
}).Info("Starting Health Endpoint")
internal.StartHealthEndpoint()
hs.Start()
}()
log.WithFields(log.Fields{
@@ -37,18 +40,21 @@ func main() {
log.WithFields(log.Fields{
"Caller": "Main",
}).Error(fmt.Sprintf("Error getting all Nodes: %s", err.Error()))
hs.SetHealthState(http.StatusServiceUnavailable)
}
ips, err := internal.GetAllIps(servers)
if err != nil {
log.WithFields(log.Fields{
"Caller": "Main",
}).Error(fmt.Sprintf("Error getting all IPs: %s", err.Error()))
hs.SetHealthState(http.StatusServiceUnavailable)
}
err = internal.RecreateIPPoolCrd(cfg, "covidnetes-pool", ips)
if err != nil {
log.WithFields(log.Fields{
"Caller": "Main",
}).Error(fmt.Sprintf("Error recreating IP Pool CRD: %s", err.Error()))
hs.SetHealthState(http.StatusServiceUnavailable)
} else {
log.WithFields(log.Fields{
"Caller": "Main",