Skip to content

Commit

Permalink
fixes related to cluster state
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 19, 2023
1 parent 6827f15 commit 5b46f02
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func kaSpawn() {
}
}

func (ci *CIStateH) CISync(doNotify bool) {
func (ci *CIStateH) CISync() {
var sm cmn.HASMod
var ciState int
var ok bool
Expand Down Expand Up @@ -146,19 +146,12 @@ func (ci *CIStateH) CISync(doNotify bool) {
}
}

if notify && doNotify {
if notify {
sm.Instance = inst
sm.State = state
sm.Vip = net.ParseIP(vip)
tk.LogIt(tk.LogInfo, "ci-change instance %s - state %s vip %v\n", inst, state, sm.Vip)
ci.CIStateUpdate(sm)
} else {
if ciState != cmn.CIStateMaster && ciState != cmn.CIStateBackup {
continue
}

nci := &ClusterInstance{State: ciState, StateStr: state}
ci.ClusterMap[inst] = nci
}
}

Expand All @@ -169,7 +162,7 @@ func (ci *CIStateH) CISync(doNotify bool) {
// CITicker - Periodic ticker for Cluster module
func (ci *CIStateH) CITicker() {
mh.mtx.Lock()
ci.CISync(true)
ci.CISync()
mh.mtx.Unlock()
}

Expand All @@ -192,7 +185,6 @@ func CIInit(spawnKa bool, kaMode bool) *CIStateH {
nCIh.SpawnKa = spawnKa
nCIh.kaMode = kaMode
nCIh.ClusterMap = make(map[string]*ClusterInstance)
// nCIh.CISync(false)

if _, ok := nCIh.ClusterMap[cmn.CIDefault]; !ok {
ci := &ClusterInstance{State: cmn.CIStateNotDefined,
Expand Down Expand Up @@ -236,7 +228,7 @@ func (h *CIStateH) CIStateGet() ([]cmn.HASMod, error) {
// CIVipGet - routine to get HA state
func (h *CIStateH) CIVipGet(inst string) (net.IP, error) {
if ci, ok := h.ClusterMap[inst]; ok {
if !ci.Vip.IsUnspecified() {
if ci.Vip != nil && !ci.Vip.IsUnspecified() {
return ci.Vip, nil
}
}
Expand Down

0 comments on commit 5b46f02

Please sign in to comment.