Add check for state directory to validator.

This commit is contained in:
Rohit Jnagal 2014-12-28 18:01:54 +00:00
parent 04fef734d2
commit cdd355421f
2 changed files with 23 additions and 10 deletions

View File

@ -70,6 +70,10 @@ type dockerContainerHandler struct {
storageDirs []string
}
func DockerStateDir() string {
return path.Join(*dockerRootDir, pathToLibcontainerState)
}
func newDockerContainerHandler(
client *docker.Client,
name string,
@ -90,14 +94,15 @@ func newDockerContainerHandler(
}
id := ContainerNameToDockerId(name)
stateDir := DockerStateDir()
handler := &dockerContainerHandler{
id: id,
client: client,
name: name,
machineInfoFactory: machineInfoFactory,
libcontainerConfigPath: path.Join(dockerRootDir, pathToLibcontainerState, id, "container.json"),
libcontainerStatePath: path.Join(dockerRootDir, pathToLibcontainerState, id, "state.json"),
libcontainerPidPath: path.Join(dockerRootDir, pathToLibcontainerState, id, "pid"),
libcontainerConfigPath: path.Join(stateDir, id, "container.json"),
libcontainerStatePath: path.Join(stateDir, id, "state.json"),
libcontainerPidPath: path.Join(stateDir, id, "pid"),
cgroupPaths: cgroupPaths,
cgroup: cgroups.Cgroup{
Parent: "/",

View File

@ -32,13 +32,15 @@ import (
"github.com/google/cadvisor/utils"
)
const ValidatePage = "/validate/"
const Supported = "[Supported, but not recommended]"
const Unsupported = "[Unsupported]"
const Recommended = "[Supported and recommended]"
const Unknown = "[Unknown]"
const VersionFormat = "%d.%d%s"
const OutputFormat = "%s: %s\n\t%s\n\n"
const (
ValidatePage = "/validate/"
Supported = "[Supported, but not recommended]"
Unsupported = "[Unsupported]"
Recommended = "[Supported and recommended]"
Unknown = "[Unknown]"
VersionFormat = "%d.%d%s"
OutputFormat = "%s: %s\n\t%s\n\n"
)
func getMajorMinor(version string) (int, int, error) {
var major, minor int
@ -170,6 +172,12 @@ func validateDockerInfo() (string, string) {
desc += "\tCgroups are being created through cgroup filesystem.\n"
}
if strings.Contains(execDriver, "native") {
stateFile := docker.DockerStateDir()
if !utils.FileExists(stateFile) {
desc += fmt.Sprintf("\tDocker container state directory %q is not accessible.\n", stateFile)
return Unsupported, desc
}
desc += fmt.Sprintf("\tDocker container state directory is at %q and is accessible.\n", stateFile)
return Recommended, desc
} else if strings.Contains(execDriver, "lxc") {
return Supported, desc