Merge pull request #696 from rjnagal/docker
Improve approximation of container creation time.
This commit is contained in:
commit
bfdbae7cb7
@ -177,7 +177,11 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
lowestTime := now
|
lowestTime := now
|
||||||
for _, cgroupPath := range self.cgroupPaths {
|
for _, cgroupPath := range self.cgroupPaths {
|
||||||
// The modified time of the cgroup directory is when the container was created.
|
// The modified time of the cgroup directory changes whenever a subcontainer is created.
|
||||||
|
// eg. /docker will have creation time matching the creation of latest docker container.
|
||||||
|
// Use clone_children as a workaround as it isn't usually modified. It is only likely changed
|
||||||
|
// immediately after creating a container.
|
||||||
|
cgroupPath = path.Join(cgroupPath, "cgroup.clone_children")
|
||||||
fi, err := os.Stat(cgroupPath)
|
fi, err := os.Stat(cgroupPath)
|
||||||
if err == nil && fi.ModTime().Before(lowestTime) {
|
if err == nil && fi.ModTime().Before(lowestTime) {
|
||||||
lowestTime = fi.ModTime()
|
lowestTime = fi.ModTime()
|
||||||
|
Loading…
Reference in New Issue
Block a user