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

View File

@ -32,13 +32,15 @@ import (
"github.com/google/cadvisor/utils" "github.com/google/cadvisor/utils"
) )
const ValidatePage = "/validate/" const (
const Supported = "[Supported, but not recommended]" ValidatePage = "/validate/"
const Unsupported = "[Unsupported]" Supported = "[Supported, but not recommended]"
const Recommended = "[Supported and recommended]" Unsupported = "[Unsupported]"
const Unknown = "[Unknown]" Recommended = "[Supported and recommended]"
const VersionFormat = "%d.%d%s" Unknown = "[Unknown]"
const OutputFormat = "%s: %s\n\t%s\n\n" VersionFormat = "%d.%d%s"
OutputFormat = "%s: %s\n\t%s\n\n"
)
func getMajorMinor(version string) (int, int, error) { func getMajorMinor(version string) (int, int, error) {
var major, minor int var major, minor int
@ -170,6 +172,12 @@ func validateDockerInfo() (string, string) {
desc += "\tCgroups are being created through cgroup filesystem.\n" desc += "\tCgroups are being created through cgroup filesystem.\n"
} }
if strings.Contains(execDriver, "native") { 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 return Recommended, desc
} else if strings.Contains(execDriver, "lxc") { } else if strings.Contains(execDriver, "lxc") {
return Supported, desc return Supported, desc