mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat & fix: Add batch operator and fix some bugs for instance group
Feature: 1. Add apis: list server by group, list group by server, bind servers, unbind servers, bind groups, unbind groups. 2. Add climc command and docs corresponding to the above newly added apis 3. Add log about binding and unbinding operator. 4. Support enable and disable instance group. Fix: 1. Set capacity zeor if there are not enough resource aboue forced instance group in one host. 2. Change the stage(real delete => pending delete) that guest leave all groups.
This commit is contained in:
@@ -64,7 +64,7 @@ func (p *SForcedGroupPredicate) Execute(u *core.Unit, c core.Candidater) (bool,
|
||||
schedDate := u.SchedData()
|
||||
|
||||
instanceGroups := c.Getter().InstanceGroups()
|
||||
minFree := math.MaxInt16
|
||||
minFree := math.MaxInt32
|
||||
for _, id := range schedDate.InstanceGroupIds {
|
||||
detail := schedDate.InstanceGroupsDetail[id]
|
||||
// SForcedGroupPredicate only deal with group whose ForceDispersion is ture
|
||||
@@ -76,7 +76,8 @@ func (p *SForcedGroupPredicate) Execute(u *core.Unit, c core.Candidater) (bool,
|
||||
free, _ = c.Getter().GetFreeGroupCount(id)
|
||||
if free < 1 {
|
||||
h.AppendPredicateFailMsg(fmt.Sprintf(
|
||||
"the number of guests with same group %s in this host has reached the upper limit", id))
|
||||
"the number of guests with same instance group '%s' in this host has reached the upper limit",
|
||||
instanceGroups[id].GetName()))
|
||||
break
|
||||
}
|
||||
} else {
|
||||
@@ -86,6 +87,10 @@ func (p *SForcedGroupPredicate) Execute(u *core.Unit, c core.Candidater) (bool,
|
||||
minFree = free
|
||||
}
|
||||
}
|
||||
// show that minFree shoule be zero
|
||||
if minFree == math.MaxInt32 {
|
||||
minFree = 0
|
||||
}
|
||||
// chose the min capacity of groups
|
||||
h.SetCapacity(int64(minFree))
|
||||
return h.GetResult()
|
||||
|
||||
Reference in New Issue
Block a user