Compare commits
No commits in common. "45ebc96c13ee508d84db4faec8a1916c3b4c466b" and "d4357767f5f0a20290c774f7796ffb7d461eba6f" have entirely different histories.
45ebc96c13
...
d4357767f5
@ -85,13 +85,13 @@ func Decom(cfg *config.Config, ownedNodes []hcloud.Server) {
|
|||||||
}
|
}
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"Caller": "Decom",
|
"Caller": "Decom",
|
||||||
}).Debugf("Node %s is running for %d", server.Name, runtime.Minute())
|
}).Debugf("Node %s is running for %f", server.Name, runtime.Minutes())
|
||||||
// Check if next check if sooner than the 60 Minute mark of the next hetzner check
|
// Check if next check if sooner than the 60 Minute mark of the next hetzner check
|
||||||
// https://docs.hetzner.com/cloud/billing/faq/#how-do-you-bill-your-servers
|
// https://docs.hetzner.com/cloud/billing/faq/#how-do-you-bill-your-servers
|
||||||
if time.Duration(runtime.Add(time.Duration(cfg.CheckInterval)*time.Minute).Minute()) < (60 * time.Minute) {
|
if (runtime + time.Duration(cfg.CheckInterval)*time.Minute) < 60 {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"Caller": "Decom",
|
"Caller": "Decom",
|
||||||
}).Infof("Skipping node termination of %s (running for %d Minutes) in Cost Optimized Mode", server.Name, runtime.Minute())
|
}).Infof("Skipping node termination of %s (running for %f Minutes) in Cost Optimized Mode", server.Name, runtime.Minutes())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,11 +175,11 @@ func RefreshNodeInfo(cfg *config.Config, serverID int) (*hcloud.Server, error) {
|
|||||||
return server, nil
|
return server, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckRuntime(cfg *config.Config, server *hcloud.Server) (time.Time, error) {
|
func CheckRuntime(cfg *config.Config, server *hcloud.Server) (time.Duration, error) {
|
||||||
server, err := RefreshNodeInfo(cfg, server.ID)
|
server, err := RefreshNodeInfo(cfg, server.ID)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Time{}, errors.New(fmt.Sprintf("Could not check Runtime: %s", err.Error()))
|
return time.Duration(0), errors.New(fmt.Sprintf("Could not check Runtime: %s", err.Error()))
|
||||||
}
|
}
|
||||||
return server.Created.Add(time.Duration(now.Minute())), nil
|
return server.Created.Sub(now), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user