Fix checking for nil-value

This commit is contained in:
Ingo Oppermann 2023-07-17 12:48:17 +02:00
parent cefd35f7da
commit 02079e30c5
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -760,10 +760,14 @@ func (c *cluster) doRebalance(emergency bool) {
continue
}
var errmessage string = ""
if e.err != nil {
if process.Error == e.err.Error() {
continue
}
errmessage = e.err.Error()
} else {
if len(process.Error) == 0 {
continue
@ -774,7 +778,7 @@ func (c *cluster) doRebalance(emergency bool) {
Operation: store.OpSetProcessError,
Data: store.CommandSetProcessError{
ID: e.processid,
Error: e.err.Error(),
Error: errmessage,
},
}
@ -1192,12 +1196,13 @@ func rebalance(have []proxy.Process, nodes map[string]proxy.NodeAbout) ([]interf
// reference currently reside.
if len(p.Config.Reference) != 0 {
for _, count := range haveReferenceAffinityMap[p.Config.Reference+"@"+p.Config.Domain] {
// Do not move the process to the node it is currently on
if count.nodeid == overloadedNodeid {
continue
}
r := resources[count.nodeid]
if r.CPU+p.CPU < r.CPULimit && r.Mem+p.Mem < r.MemLimit && !r.IsThrottling {
if hasNodeEnoughResources(r, p.CPU, p.Mem) {
availableNodeid = count.nodeid
break
}
@ -1214,7 +1219,7 @@ func rebalance(have []proxy.Process, nodes map[string]proxy.NodeAbout) ([]interf
r := node.Resources
if r.CPU+p.CPU < r.CPULimit && r.Mem+p.Mem < r.MemLimit && !r.IsThrottling {
if hasNodeEnoughResources(r, p.CPU, p.Mem) {
availableNodeid = id
break
}