mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Automatic merge from release/2.1.0 -> master
* commit 'b2c0bc8e63e2be59980d5b2106ea4a8880915b6d': 修正: 调度器指定网络批量失败的bug
This commit is contained in:
@@ -163,15 +163,20 @@ func (c *MinCounters) Add(counter Counter) {
|
||||
}
|
||||
|
||||
func (c *MinCounters) GetCount() int64 {
|
||||
n := EmptyCapacity
|
||||
for _, c0 := range c.counters {
|
||||
if len(c.counters) == 0 {
|
||||
return EmptyCapacity
|
||||
}
|
||||
minCount := c.counters[0].GetCount()
|
||||
if len(c.counters) == 1 {
|
||||
return minCount
|
||||
}
|
||||
for _, c0 := range c.counters[1:] {
|
||||
count := c0.GetCount()
|
||||
if count != EmptyCapacity && count < n {
|
||||
n = count
|
||||
if count < minCount {
|
||||
minCount = count
|
||||
}
|
||||
}
|
||||
|
||||
return n
|
||||
return minCount
|
||||
}
|
||||
|
||||
type Capacity struct {
|
||||
@@ -448,7 +453,9 @@ func (u *Unit) SetCapacity(id string, name string, capacity Counter) error {
|
||||
|
||||
// Capacity must >= 0
|
||||
if !validateCapacityInput(capacity) {
|
||||
return fmt.Errorf("Capacity invalid: %d", capacity)
|
||||
err := fmt.Errorf("Capacity counter invalid: %#v, count: %d", capacity, capacity.GetCount())
|
||||
log.Errorf("SetCapacity error: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.V(10).Debugf("%q setCapacity id: %s, capacity: %d", name, id, capacity.GetCount())
|
||||
|
||||
Reference in New Issue
Block a user