Skip to content

Commit 812f319

Browse files
cpuguy83thaJeztah
authored andcommitted
Add containerd connection info to info endpoint (API v1.46)
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. - docs/api: update version history - daemon: add fillContainerdInfo utility - api: update swagger file with new types Signed-off-by: Brian Goff <[email protected]> Signed-off-by: Bjorn Neergaard <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent eb360ef commit 812f319

5 files changed

Lines changed: 116 additions & 0 deletions

File tree

api/server/router/system/system_routes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
9797
info.Runtimes[k] = system.RuntimeWithStatus{Runtime: rt.Runtime}
9898
}
9999
}
100+
if versions.LessThan(version, "1.46") {
101+
// Containerd field introduced in API v1.46.
102+
info.Containerd = nil
103+
}
100104
if versions.GreaterThanOrEqualTo(version, "1.42") {
101105
info.KernelMemory = false
102106
}

api/swagger.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5824,6 +5824,58 @@ definitions:
58245824
example:
58255825
- "/etc/cdi"
58265826
- "/var/run/cdi"
5827+
Containerd:
5828+
$ref: "#/definitions/ContainerdInfo"
5829+
x-nullable: true
5830+
5831+
ContainerdInfo:
5832+
description: |
5833+
Information for connecting to the containerd instance that is used by the daemon.
5834+
This is included for debugging purposes only.
5835+
type: "object"
5836+
properties:
5837+
Address:
5838+
description: "The address of the containerd socket."
5839+
type: "string"
5840+
example: "/run/containerd/containerd.sock"
5841+
Namespaces:
5842+
description: |
5843+
The namespaces that the daemon uses for running containers and
5844+
plugins in containerd. These namespaces can be configured in the
5845+
daemon configuration, and are considered to be used exclusively
5846+
by the daemon, Tampering with the containerd instance may cause
5847+
unexpected behavior.
5848+
5849+
As these namespaces are considered to be exclusively accessed
5850+
by the daemon, it is not recommended to change these values,
5851+
or to change them to a value that is used by other systems,
5852+
such as cri-containerd.
5853+
type: "object"
5854+
properties:
5855+
Containers:
5856+
description: |
5857+
The default containerd namespace used for containers managed
5858+
by the daemon.
5859+
5860+
The default namespace for containers is "moby", but will be
5861+
suffixed with the `<uid>.<gid>` of the remapped `root` if
5862+
user-namespaces are enabled and the containerd image-store
5863+
is used.
5864+
type: "string"
5865+
default: "moby"
5866+
example: "moby"
5867+
Plugins:
5868+
description: |
5869+
The default containerd namespace used for plugins managed by
5870+
the daemon.
5871+
5872+
The default namespace for plugins is "plugins.moby", but will be
5873+
suffixed with the `<uid>.<gid>` of the remapped `root` if
5874+
user-namespaces are enabled and the containerd image-store
5875+
is used.
5876+
type: "string"
5877+
default: "plugins.moby"
5878+
example: "plugins.moby"
58275879

58285880
# PluginsInfo is a temp struct holding Plugins name
58295881
# registered with docker daemon. It is used by Info struct

api/types/system/info.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ type Info struct {
7575
DefaultAddressPools []NetworkAddressPool `json:",omitempty"`
7676
CDISpecDirs []string
7777

78+
Containerd *ContainerdInfo `json:",omitempty"`
79+
7880
// Legacy API fields for older API versions.
7981
legacyFields
8082

@@ -85,6 +87,43 @@ type Info struct {
8587
Warnings []string
8688
}
8789

90+
// ContainerdInfo holds information about the containerd instance used by the daemon.
91+
type ContainerdInfo struct {
92+
// Address is the path to the containerd socket.
93+
Address string `json:",omitempty"`
94+
// Namespaces is the containerd namespaces used by the daemon.
95+
Namespaces ContainerdNamespaces
96+
}
97+
98+
// ContainerdNamespaces reflects the containerd namespaces used by the daemon.
99+
//
100+
// These namespaces can be configured in the daemon configuration, and are
101+
// considered to be used exclusively by the daemon,
102+
//
103+
// As these namespaces are considered to be exclusively accessed
104+
// by the daemon, it is not recommended to change these values,
105+
// or to change them to a value that is used by other systems,
106+
// such as cri-containerd.
107+
type ContainerdNamespaces struct {
108+
// Containers holds the default containerd namespace used for
109+
// containers managed by the daemon.
110+
//
111+
// The default namespace for containers is "moby", but will be
112+
// suffixed with the `<uid>.<gid>` of the remapped `root` if
113+
// user-namespaces are enabled and the containerd image-store
114+
// is used.
115+
Containers string
116+
117+
// Plugins holds the default containerd namespace used for
118+
// plugins managed by the daemon.
119+
//
120+
// The default namespace for plugins is "moby", but will be
121+
// suffixed with the `<uid>.<gid>` of the remapped `root` if
122+
// user-namespaces are enabled and the containerd image-store
123+
// is used.
124+
Plugins string
125+
}
126+
88127
type legacyFields struct {
89128
ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions.
90129
}

daemon/info.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ func (daemon *Daemon) SystemInfo(ctx context.Context) (*system.Info, error) {
8282

8383
daemon.fillContainerStates(v)
8484
daemon.fillDebugInfo(ctx, v)
85+
daemon.fillContainerdInfo(v, &cfg.Config)
8586
daemon.fillAPIInfo(v, &cfg.Config)
87+
8688
// Retrieve platform specific info
8789
if err := daemon.fillPlatformInfo(ctx, v, sysInfo, cfg); err != nil {
8890
return nil, err
@@ -227,6 +229,22 @@ func (daemon *Daemon) fillDebugInfo(ctx context.Context, v *system.Info) {
227229
v.NFd = fileutils.GetTotalUsedFds(ctx)
228230
v.NGoroutines = runtime.NumGoroutine()
229231
v.NEventsListener = daemon.EventsService.SubscribersCount()
232+
233+
}
234+
235+
// fillContainerdInfo provides information about the containerd configuration
236+
// for debugging purposes.
237+
func (daemon *Daemon) fillContainerdInfo(v *system.Info, cfg *config.Config) {
238+
if cfg.ContainerdAddr == "" {
239+
return
240+
}
241+
v.Containerd = &system.ContainerdInfo{
242+
Address: cfg.ContainerdAddr,
243+
Namespaces: system.ContainerdNamespaces{
244+
Containers: cfg.ContainerdNamespace,
245+
Plugins: cfg.ContainerdPluginNamespace,
246+
},
247+
}
230248
}
231249

232250
func (daemon *Daemon) fillAPIInfo(v *system.Info, cfg *config.Config) {

docs/api/version-history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ keywords: "API, Docker, rcli, REST, documentation"
1717

1818
[Docker Engine API v1.46](https://docs.docker.com/engine/api/v1.46/) documentation
1919

20+
* `GET /info` now includes a `Containerd` field containing information about
21+
the location of the containerd API socket and containerd namespaces used
22+
by the daemon to run containers and plugins.
2023
* `POST /containers/create` field `NetworkingConfig.EndpointsConfig.DriverOpts`,
2124
and `POST /networks/{id}/connect` field `EndpointsConfig.DriverOpts`, now
2225
support label `com.docker.network.endpoint.sysctls` for setting per-interface

0 commit comments

Comments
 (0)