Renamed mount and removed dead code
This commit is contained in:
parent
751de4a0c9
commit
6b267575ad
@ -16,11 +16,6 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
|||||||
t.Errorf("Cannot find network interface in %s", cHints)
|
t.Errorf("Cannot find network interface in %s", cHints)
|
||||||
}
|
}
|
||||||
|
|
||||||
var mountDirs [5]string
|
|
||||||
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
|
||||||
mountDirs[i] = mountDir.HostDir
|
|
||||||
}
|
|
||||||
|
|
||||||
correctMountDirs := [...]string{
|
correctMountDirs := [...]string{
|
||||||
"/var/run/nm-sdc1",
|
"/var/run/nm-sdc1",
|
||||||
"/var/run/nm-sdb3",
|
"/var/run/nm-sdb3",
|
||||||
@ -29,6 +24,10 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
|||||||
"/var/run/openvswitch/db.sock",
|
"/var/run/openvswitch/db.sock",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(cHints.AllHosts[0].Mounts) == 0 {
|
||||||
|
t.Errorf("Cannot find any mounts")
|
||||||
|
}
|
||||||
|
|
||||||
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
||||||
if correctMountDirs[i] != mountDir.HostDir {
|
if correctMountDirs[i] != mountDir.HostDir {
|
||||||
t.Errorf("Cannot find mount %s in %s", mountDir.HostDir, cHints)
|
t.Errorf("Cannot find mount %s in %s", mountDir.HostDir, cHints)
|
||||||
|
@ -44,8 +44,8 @@ type rawContainerHandler struct {
|
|||||||
stopWatcher chan error
|
stopWatcher chan error
|
||||||
watches map[string]struct{}
|
watches map[string]struct{}
|
||||||
fsInfo fs.FsInfo
|
fsInfo fs.FsInfo
|
||||||
networkInterface *networkInterface
|
networkInterface *networkInterface
|
||||||
mounts []mount
|
externalMounts []mount
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRawContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, machineInfoFactory info.MachineInfoFactory) (container.ContainerHandler, error) {
|
func newRawContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, machineInfoFactory info.MachineInfoFactory) (container.ContainerHandler, error) {
|
||||||
@ -58,11 +58,11 @@ func newRawContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, mac
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var networkInterface *networkInterface
|
var networkInterface *networkInterface
|
||||||
var mounts []mount
|
var externalMounts []mount
|
||||||
for _, container := range cHints.AllHosts {
|
for _, container := range cHints.AllHosts {
|
||||||
if name == container.FullName {
|
if name == container.FullName {
|
||||||
networkInterface = container.NetworkInterface
|
networkInterface = container.NetworkInterface
|
||||||
mounts = container.Mounts
|
externalMounts = container.Mounts
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ func newRawContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, mac
|
|||||||
watches: make(map[string]struct{}),
|
watches: make(map[string]struct{}),
|
||||||
fsInfo: fsInfo,
|
fsInfo: fsInfo,
|
||||||
networkInterface: networkInterface,
|
networkInterface: networkInterface,
|
||||||
mounts: mounts,
|
externalMounts: externalMounts,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fs.
|
// Fs.
|
||||||
if self.name == "/" || self.mounts != nil {
|
if self.name == "/" || self.externalMounts != nil {
|
||||||
spec.HasFilesystem = true
|
spec.HasFilesystem = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,10 +190,10 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
|||||||
for _, fs := range filesystems {
|
for _, fs := range filesystems {
|
||||||
stats.Filesystem = append(stats.Filesystem, info.FsStats{fs.Device, fs.Capacity, fs.Capacity - fs.Free})
|
stats.Filesystem = append(stats.Filesystem, info.FsStats{fs.Device, fs.Capacity, fs.Capacity - fs.Free})
|
||||||
}
|
}
|
||||||
} else if len(self.mounts) > 0 {
|
} else if len(self.externalMounts) > 0 {
|
||||||
var mountSet map[string]struct{}
|
var mountSet map[string]struct{}
|
||||||
mountSet = make(map[string]struct{})
|
mountSet = make(map[string]struct{})
|
||||||
for _, mount := range self.mounts {
|
for _, mount := range self.externalMounts {
|
||||||
mountSet[mount.HostDir] = struct{}{}
|
mountSet[mount.HostDir] = struct{}{}
|
||||||
}
|
}
|
||||||
filesystems, err := self.fsInfo.GetFsInfoForPath(mountSet)
|
filesystems, err := self.fsInfo.GetFsInfoForPath(mountSet)
|
||||||
|
Loading…
Reference in New Issue
Block a user