Add containerd connection info to info endpoint

This will be used in the next commit to test that changes are propagated
to the containerd store.
It is also just generally useful for debugging purposes.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
Brian Goff 2024-01-28 19:41:41 +00:00 committed by Bjorn Neergaard
parent 8b79278316
commit 84c0103448
No known key found for this signature in database
3 changed files with 56 additions and 0 deletions

View file

@ -5436,6 +5436,35 @@ definitions:
example:
- "/etc/cdi"
- "/var/run/cdi"
Containerd:
$ref: "#/definitions/ContainerdInfo"
x-nullable: true
ContainerdInfo:
description: |
Information for connecting to the containerd instance that is used by the daemon.
This is included for debugging purposes only.
Tampering with the containerd instance may cause unexpected behavior.
type: "object"
properties:
Address:
description: "The address of the containerd socket."
type: "string"
Namespaces:
description: "The namespaces that are used by containerd."
type: "object"
properties:
Containers:
description: "The namespace that is used for containers."
type: "string"
Plugins:
description: "The namespace that is used for plugins."
type: "string"
example:
Address: "/run/containerd/containerd.sock"
Namespaces:
Containers: "moby"
Plugins: "plugins.moby"
# PluginsInfo is a temp struct holding Plugins name
# registered with docker daemon. It is used by Info struct

View file

@ -75,6 +75,8 @@ type Info struct {
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
CDISpecDirs []string
Containerd *ContainerdInfo `json:",omitempty"`
// Legacy API fields for older API versions.
legacyFields
@ -85,6 +87,20 @@ type Info struct {
Warnings []string
}
// ContainerdInfo holds information about the containerd instance used by the daemon.
type ContainerdInfo struct {
// Address is the path to the containerd socket.
Address string `json:",omitempty"`
// Namespaces is the containerd namespaces used by the daemon.
Namespaces ContainerdNamespaces
}
// ContainerdNamespaces reflects the containerd namespaces used by the daemon.
type ContainerdNamespaces struct {
Containers string
Plugins string
}
type legacyFields struct {
ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions.
}

View file

@ -227,6 +227,17 @@ func (daemon *Daemon) fillDebugInfo(ctx context.Context, v *system.Info) {
v.NFd = fileutils.GetTotalUsedFds(ctx)
v.NGoroutines = runtime.NumGoroutine()
v.NEventsListener = daemon.EventsService.SubscribersCount()
config := daemon.Config()
if config.ContainerdAddr != "" {
v.Containerd = &system.ContainerdInfo{
Address: config.ContainerdAddr,
Namespaces: system.ContainerdNamespaces{
Containers: config.ContainerdNamespace,
Plugins: config.ContainerdPluginNamespace,
},
}
}
}
func (daemon *Daemon) fillAPIInfo(v *system.Info, cfg *config.Config) {