fixed naming
This commit is contained in:
parent
f657bbbf28
commit
eb2ed92605
1 changed files with 18 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/api/types"
|
"git.giftfish.de/ston1th/haproxy-lb/pkg/api/types"
|
||||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/api/v1/schema"
|
"git.giftfish.de/ston1th/haproxy-lb/pkg/api/v1/schema"
|
||||||
|
|
@ -38,8 +39,18 @@ func name(c, n string) string {
|
||||||
return c + "/" + n
|
return c + "/" + n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lbsep = "_"
|
||||||
|
|
||||||
func lbname(c, n string) string {
|
func lbname(c, n string) string {
|
||||||
return c + "_" + n
|
return c + lbsep + n
|
||||||
|
}
|
||||||
|
|
||||||
|
func convlbname(n string) string {
|
||||||
|
a := strings.SplitN(n, lbsep, 1)
|
||||||
|
if len(a) != 2 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return name(a[0], a[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIP(cidr string) (string, error) {
|
func getIP(cidr string) (string, error) {
|
||||||
|
|
@ -191,13 +202,18 @@ func lbClusterHandler(ctx *types.Context) {
|
||||||
ctx.Err(types.ErrFollower)
|
ctx.Err(types.ErrFollower)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for name, _ := range m {
|
for n, _ := range m {
|
||||||
|
name := convlbname(n)
|
||||||
cidr, err := ctx.Data.DB.GetCIDR(name)
|
cidr, err := ctx.Data.DB.GetCIDR(name)
|
||||||
if err != nil && err != cluster.ErrKeyNotFound {
|
if err != nil && err != cluster.ErrKeyNotFound {
|
||||||
ctx.Log.Error(err, "error reading IP of loadbalancer", "cluster", cl, "name", name)
|
ctx.Log.Error(err, "error reading IP of loadbalancer", "cluster", cl, "name", name)
|
||||||
ctx.Err(types.ErrISE)
|
ctx.Err(types.ErrISE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if err == cluster.ErrKeyNotFound {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
err = ctx.Data.Net.FreeCIDR(cidr)
|
err = ctx.Data.Net.FreeCIDR(cidr)
|
||||||
if err != nil && err != cluster.ErrKeyNotFound {
|
if err != nil && err != cluster.ErrKeyNotFound {
|
||||||
ctx.Log.Error(err, "error freeing IP of loadbalancer", "cluster", cl, "name", name)
|
ctx.Log.Error(err, "error freeing IP of loadbalancer", "cluster", cl, "name", name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue