fix handling if floating ip is not yet assigned
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
This commit is contained in:
@ -78,11 +78,13 @@ func AttachFloatingIpToNode(cfg *Config, server hcloud.Server) error {
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not find Floating IP by name: %s", err.Error()))
|
||||
}
|
||||
if floatingIP.Server.ID == server.ID {
|
||||
log.WithFields(log.Fields{
|
||||
"Caller": "AttachFloatingIpToNode",
|
||||
}).Info(fmt.Sprintf("Floating IP %s already assigned to Node %s", cfg.FloatingIPName, server.Name))
|
||||
return nil
|
||||
if floatingIP.Server != nil {
|
||||
if floatingIP.Server.ID == server.ID {
|
||||
log.WithFields(log.Fields{
|
||||
"Caller": "AttachFloatingIpToNode",
|
||||
}).Info(fmt.Sprintf("Floating IP %s already assigned to Node %s", cfg.FloatingIPName, server.Name))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
_, _, err = client.FloatingIP.Assign(context.TODO(), floatingIP, &server)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user