Avoid storage usagge calculations when aufs driver is not being used.

This commit is contained in:
Vishnu Kannan 2014-10-07 08:34:59 +00:00
parent 5e8fecea6a
commit 0699e7029d
4 changed files with 28 additions and 5 deletions

View File

@ -39,6 +39,9 @@ type dockerFactory struct {
// Whether this system is using systemd.
useSystemd bool
// Whether docker is running with AUFS storage driver.
usesAufsDriver bool
client *docker.Client
}
@ -57,6 +60,7 @@ func (self *dockerFactory) NewContainerHandler(name string) (handler container.C
self.machineInfoFactory,
self.useSystemd,
*dockerRootDir,
self.usesAufsDriver,
)
return
}
@ -148,10 +152,19 @@ func Register(factory info.MachineInfoFactory) error {
return fmt.Errorf("Docker found, but not using native exec driver")
}
usesAufsDriver := false
for _, val := range *information {
if strings.Contains(val, "Driver=") && strings.Contains(val, "aufs") {
usesAufsDriver = true
break
}
}
f := &dockerFactory{
machineInfoFactory: factory,
useSystemd: systemd.UseSystemd(),
client: client,
usesAufsDriver: usesAufsDriver,
}
if f.useSystemd {
glog.Infof("System is using systemd")

View File

@ -54,6 +54,7 @@ type dockerContainerHandler struct {
useSystemd bool
libcontainerStateDir string
cgroup cgroups.Cgroup
usesAufsDriver bool
fsInfo fs.FsInfo
storageDirs []string
}
@ -64,6 +65,7 @@ func newDockerContainerHandler(
machineInfoFactory info.MachineInfoFactory,
useSystemd bool,
dockerRootDir string,
usesAufsDriver bool,
) (container.ContainerHandler, error) {
fsInfo, err := fs.NewFsInfo()
if err != nil {
@ -79,6 +81,7 @@ func newDockerContainerHandler(
Parent: "/",
Name: name,
},
usesAufsDriver: usesAufsDriver,
fsInfo: fsInfo,
}
handler.storageDirs = append(handler.storageDirs, path.Join(dockerRootDir, pathToAufsDir, path.Base(name)))
@ -228,12 +231,19 @@ func (self *dockerContainerHandler) GetSpec() (spec info.ContainerSpec, err erro
spec = libcontainerConfigToContainerSpec(libcontainerConfig, mi)
if self.usesAufsDriver {
spec.HasFilesystem = true
}
return
}
func (self *dockerContainerHandler) getFsStats(stats *info.ContainerStats) error {
// No support for non-aufs storage drivers.
if !self.usesAufsDriver {
return nil
}
// As of now we assume that all the storage dirs are on the same device.
// The first storage dir will be that of the image layers.
deviceInfo, err := self.fsInfo.GetDirFsDevice(self.storageDirs[0])

View File

@ -239,7 +239,7 @@ type FsStats struct {
Limit uint64 `json:"capacity"`
// Number of bytes that is consumed by the container on this filesystem.
Usage uint64 `json:"free"`
Usage uint64 `json:"usage"`
}
type ContainerStats struct {

View File

@ -61,8 +61,8 @@ func buildTrace(cpu, mem []uint64, duration time.Duration) []*info.ContainerStat
stats.Filesystem = make([]info.FsStats, 1)
stats.Filesystem[0].Device = "/dev/sda1"
stats.Filesystem[0].Capacity = 1024000000
stats.Filesystem[0].Free = 1024000
stats.Filesystem[0].Limit = 1024000000
stats.Filesystem[0].Usage = 1024000
ret[i] = stats
}
return ret