Add DebugInfo() API and put the information on /validate
This commit is contained in:
parent
1f248ee956
commit
0525d40a4a
@ -149,6 +149,10 @@ func (self *dockerFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
|||||||
return true, canAccept, nil
|
return true, canAccept, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *dockerFactory) DebugInfo() map[string][]string {
|
||||||
|
return map[string][]string{}
|
||||||
|
}
|
||||||
|
|
||||||
func parseDockerVersion(full_version_string string) ([]int, error) {
|
func parseDockerVersion(full_version_string string) ([]int, error) {
|
||||||
version_regexp_string := "(\\d+)\\.(\\d+)\\.(\\d+)"
|
version_regexp_string := "(\\d+)\\.(\\d+)\\.(\\d+)"
|
||||||
version_re := regexp.MustCompile(version_regexp_string)
|
version_re := regexp.MustCompile(version_regexp_string)
|
||||||
|
@ -30,6 +30,9 @@ type ContainerHandlerFactory interface {
|
|||||||
|
|
||||||
// Name of the factory.
|
// Name of the factory.
|
||||||
String() string
|
String() string
|
||||||
|
|
||||||
|
// Returns debugging information. Map of lines per category.
|
||||||
|
DebugInfo() map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(vmarmol): Consider not making this global.
|
// TODO(vmarmol): Consider not making this global.
|
||||||
@ -90,3 +93,17 @@ func ClearContainerHandlerFactories() {
|
|||||||
|
|
||||||
factories = make([]ContainerHandlerFactory, 0, 4)
|
factories = make([]ContainerHandlerFactory, 0, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DebugInfo() map[string][]string {
|
||||||
|
factoriesLock.RLock()
|
||||||
|
defer factoriesLock.RUnlock()
|
||||||
|
|
||||||
|
// Get debug information for all factories.
|
||||||
|
out := make(map[string][]string)
|
||||||
|
for _, factory := range factories {
|
||||||
|
for k, v := range factory.DebugInfo() {
|
||||||
|
out[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
@ -31,6 +31,10 @@ func (self *mockContainerHandlerFactory) String() string {
|
|||||||
return self.Name
|
return self.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *mockContainerHandlerFactory) DebugInfo() map[string][]string {
|
||||||
|
return map[string][]string{}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *mockContainerHandlerFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
func (self *mockContainerHandlerFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
||||||
return self.CanHandleValue, self.CanAcceptValue, nil
|
return self.CanHandleValue, self.CanAcceptValue, nil
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,9 @@ type Manager interface {
|
|||||||
|
|
||||||
// Get details about interesting docker images.
|
// Get details about interesting docker images.
|
||||||
DockerImages() ([]DockerImage, error)
|
DockerImages() ([]DockerImage, error)
|
||||||
|
|
||||||
|
// Returns debugging information. Map of lines per category.
|
||||||
|
DebugInfo() map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// New takes a memory storage and returns a new manager.
|
// New takes a memory storage and returns a new manager.
|
||||||
@ -1131,3 +1134,7 @@ func (m *manager) DockerInfo() (DockerStatus, error) {
|
|||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *manager) DebugInfo() map[string][]string {
|
||||||
|
return container.DebugInfo()
|
||||||
|
}
|
||||||
|
@ -313,6 +313,13 @@ func HandleRequest(w http.ResponseWriter, containerManager manager.Manager) erro
|
|||||||
|
|
||||||
ioSchedulerValidation, desc := validateIoScheduler(containerManager)
|
ioSchedulerValidation, desc := validateIoScheduler(containerManager)
|
||||||
out += fmt.Sprintf(OutputFormat, "Block device setup", ioSchedulerValidation, desc)
|
out += fmt.Sprintf(OutputFormat, "Block device setup", ioSchedulerValidation, desc)
|
||||||
|
|
||||||
|
// Output debug info.
|
||||||
|
debugInfo := containerManager.DebugInfo()
|
||||||
|
for category, lines := range debugInfo {
|
||||||
|
out += fmt.Sprintf(OutputFormat, category, "", strings.Join(lines, "\n\t"))
|
||||||
|
}
|
||||||
|
|
||||||
_, err = w.Write([]byte(out))
|
_, err = w.Write([]byte(out))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user