rename back to LagInMB
This commit is contained in:
parent
1b0d51a900
commit
f29c2f864f
|
|
@ -514,11 +514,11 @@ func (c *Cluster) getSwitchoverCandidate(master *v1.Pod) (spec.NamespacedName, e
|
|||
// pick candidate with lowest lag
|
||||
// if sync_standby replicas were found assume synchronous_mode is enabled and ignore other candidates list
|
||||
if len(syncCandidates) > 0 {
|
||||
sort.Slice(syncCandidates, func(i, j int) bool { return syncCandidates[i].Lag < syncCandidates[j].Lag })
|
||||
sort.Slice(syncCandidates, func(i, j int) bool { return syncCandidates[i].LagInMb < syncCandidates[j].LagInMb })
|
||||
return spec.NamespacedName{Namespace: master.Namespace, Name: syncCandidates[0].Name}, nil
|
||||
}
|
||||
if len(candidates) > 0 {
|
||||
sort.Slice(candidates, func(i, j int) bool { return candidates[i].Lag < candidates[j].Lag })
|
||||
sort.Slice(candidates, func(i, j int) bool { return candidates[i].LagInMb < candidates[j].LagInMb })
|
||||
return spec.NamespacedName{Namespace: master.Namespace, Name: candidates[0].Name}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ type ClusterMember struct {
|
|||
Role string `json:"role"`
|
||||
State string `json:"state"`
|
||||
Timeline int `json:"timeline"`
|
||||
Lag int `json:"lag"`
|
||||
LagInMb int `json:"lag"`
|
||||
}
|
||||
|
||||
// MemberDataPatroni child element
|
||||
|
|
|
|||
|
|
@ -95,19 +95,19 @@ func TestGetClusterMembers(t *testing.T) {
|
|||
Role: "leader",
|
||||
State: "running",
|
||||
Timeline: 1,
|
||||
Lag: 0,
|
||||
LagInMb: 0,
|
||||
}, {
|
||||
Name: "acid-test-cluster-1",
|
||||
Role: "sync_standby",
|
||||
State: "running",
|
||||
Timeline: 1,
|
||||
Lag: 0,
|
||||
LagInMb: 0,
|
||||
}, {
|
||||
Name: "acid-test-cluster-2",
|
||||
Role: "replica",
|
||||
State: "running",
|
||||
Timeline: 1,
|
||||
Lag: 0,
|
||||
LagInMb: 0,
|
||||
}}
|
||||
|
||||
json := `{"members": [{"name": "acid-test-cluster-0", "role": "leader", "state": "running", "api_url": "http://192.168.100.1:8008/patroni", "host": "192.168.100.1", "port": 5432, "timeline": 1}, {"name": "acid-test-cluster-1", "role": "sync_standby", "state": "running", "api_url": "http://192.168.100.2:8008/patroni", "host": "192.168.100.2", "port": 5432, "timeline": 1, "lag": 0}, {"name": "acid-test-cluster-2", "role": "replica", "state": "running", "api_url": "http://192.168.100.3:8008/patroni", "host": "192.168.100.3", "port": 5432, "timeline": 1, "lag": 0}]}`
|
||||
|
|
|
|||
Loading…
Reference in New Issue