stats returned in chronological order
This commit is contained in:
parent
43346e5f29
commit
e9111b5527
@ -95,18 +95,15 @@ func (self *containerStorage) RecentStats(numStats int) ([]*info.ContainerStats,
|
|||||||
if self.recentStats.Len() < numStats || numStats < 0 {
|
if self.recentStats.Len() < numStats || numStats < 0 {
|
||||||
numStats = self.recentStats.Len()
|
numStats = self.recentStats.Len()
|
||||||
}
|
}
|
||||||
ret := make([]*info.ContainerStats, 0, numStats)
|
ret := make([]*info.ContainerStats, numStats)
|
||||||
e := self.recentStats.Front()
|
e := self.recentStats.Front()
|
||||||
for i := 0; i < numStats; i++ {
|
for i := numStats - 1; i >= 0; i-- {
|
||||||
data, ok := e.Value.(*info.ContainerStats)
|
data, ok := e.Value.(*info.ContainerStats)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("The %vth element is not a ContainerStats", i)
|
return nil, fmt.Errorf("The %vth element is not a ContainerStats", i)
|
||||||
}
|
}
|
||||||
ret = append(ret, data)
|
ret[i] = data
|
||||||
e = e.Next()
|
e = e.Next()
|
||||||
if e == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user