refresh node information
All checks were successful
Pipeline was successful

This commit is contained in:
Tobias Trabelsi 2023-11-04 22:37:09 +01:00
parent 047e859efa
commit e304781ba3
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E
2 changed files with 15 additions and 0 deletions

View File

@ -59,6 +59,12 @@ func main() {
}).Fatal(fmt.Sprintf("Error spawning new agent: %s", err.Error())) }).Fatal(fmt.Sprintf("Error spawning new agent: %s", err.Error()))
} }
for { for {
server, err = hetzner.RefreshNodeInfo(cfg, server.ID)
if err != nil {
log.WithFields(log.Fields{
"Caller": "Main",
}).Fatal(fmt.Sprintf("Failed to start Agent: %s", err.Error()))
}
if server.Status == hcloud.ServerStatusRunning { if server.Status == hcloud.ServerStatusRunning {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"Caller": "Main", "Caller": "Main",

View File

@ -134,3 +134,12 @@ func DecomNode(cfg *config.Config, server *hcloud.Server) error {
} }
return nil return nil
} }
func RefreshNodeInfo(cfg *config.Config, serverID int) (*hcloud.Server, error) {
client := hcloud.NewClient(hcloud.WithToken(cfg.HcloudToken))
server, _, err := client.Server.GetByID(context.Background(), serverID)
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not refresh server info: %s", err.Error()))
}
return server, nil
}