From 080f8a9592920d0464e5839ac3e5c384066cd0d6 Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Thu, 21 May 2015 14:40:23 -0700 Subject: [PATCH] Add managed containers to debug output --- manager/manager.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/manager/manager.go b/manager/manager.go index d06f8e80..e5e30952 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -1136,5 +1136,36 @@ func (m *manager) DockerInfo() (DockerStatus, error) { } func (m *manager) DebugInfo() map[string][]string { - return container.DebugInfo() + debugInfo := container.DebugInfo() + + // Get unique containers. + var conts map[*containerData]struct{} + func() { + m.containersLock.RLock() + defer m.containersLock.RUnlock() + + conts = make(map[*containerData]struct{}, len(m.containers)) + for _, c := range m.containers { + conts[c] = struct{}{} + } + }() + + // List containers. + lines := make([]string, 0, len(conts)) + for cont := range conts { + lines = append(lines, cont.info.Name) + if cont.info.Namespace != "" { + lines = append(lines, fmt.Sprintf("\tNamespace: %s", cont.info.Namespace)) + } + + if len(cont.info.Aliases) != 0 { + lines = append(lines, "\tAliases:") + for _, alias := range cont.info.Aliases { + lines = append(lines, fmt.Sprintf("\t\t%s", alias)) + } + } + } + + debugInfo["Managed containers"] = lines + return debugInfo }