cleanup and refactor health service
This commit is contained in:
@@ -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",
|
||||
|
Reference in New Issue
Block a user