Skip to content

Commit

Permalink
Merge pull request #228 from loxilb-io/zoning-names
Browse files Browse the repository at this point in the history
PR - Better handling of zone names
  • Loading branch information
TrekkieCoder authored Jan 12, 2025
2 parents 1b9318d + fc6faae commit b8012d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func (m *Manager) addLoadBalancer(svc *corev1.Service) error {
addNewLbCacheEntryChan := make(chan *LbCacheEntry)
defer close(addNewLbCacheEntryChan)
go func() {
zoneInstName := "default"
zoneInstName := api.GenZoneInstName(m.networkConfig.Zone, 0)
if overrideZoneInst != "" {
zoneInstName = overrideZoneInst
} else {
Expand Down Expand Up @@ -2372,6 +2372,28 @@ loop:
}

for instName, vi := range aliveClient.InstRoles {
firstZoneName := api.GenZoneInstName(m.networkConfig.Zone, 0)
if instName == firstZoneName && m.networkConfig.Zone != api.CIDefault {
defaultZoneName := api.GenZoneInstName(api.CIDefault, 0)
cisModel, err := m.makeLoxiLBCIStatusModel(instName, m.networkConfig.SetRoles, aliveClient)
cisModel.Instance = defaultZoneName
if err == nil {
for retry := 0; retry < 5; retry++ {
err = func(cisModel *api.CIStatusModel) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
return aliveClient.CIStatus().Create(ctx, cisModel)
}(&cisModel)
if err == nil {
klog.Infof("loxilb-lb(%s): set-role-master(%s:%v) - OK", aliveClient.Host, defaultZoneName, vi.MasterLB)
break
} else {
klog.Infof("loxilb-lb(%s): set-role-master(%s:%v) - failed(%d)", aliveClient.Host, defaultZoneName, vi.MasterLB, retry)
time.Sleep(1 * time.Second)
}
}
}
}
cisModel, err := m.makeLoxiLBCIStatusModel(instName, m.networkConfig.SetRoles, aliveClient)
if err == nil {
for retry := 0; retry < 5; retry++ {
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func NewLoxiClientPool() *LoxiClientPool {
}
}

const (
CIDefault = "llb-inst0"
)

type LoxiClient struct {
RestClient *RESTClient
InstRoles map[string]*LoxiZoneInst
Expand Down

0 comments on commit b8012d3

Please sign in to comment.