Merge pull request #46647 from AkihiroSuda/runtime-status
docker info: expose runtime features ("rro" mount mode, etc.), in machine-parsable format
This commit is contained in:
commit
79c759393f
6 changed files with 71 additions and 6 deletions
|
@ -91,6 +91,12 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
|
|||
info.OperatingSystem = "<unknown>"
|
||||
}
|
||||
}
|
||||
if versions.LessThan(version, "1.44") {
|
||||
for k, rt := range info.Runtimes {
|
||||
// Status field introduced inl API v1.44.
|
||||
info.Runtimes[k] = system.RuntimeWithStatus{Runtime: rt.Runtime}
|
||||
}
|
||||
}
|
||||
if versions.GreaterThanOrEqualTo(version, "1.42") {
|
||||
info.KernelMemory = false
|
||||
}
|
||||
|
|
|
@ -5618,6 +5618,28 @@ definitions:
|
|||
items:
|
||||
type: "string"
|
||||
example: ["--debug", "--systemd-cgroup=false"]
|
||||
status:
|
||||
description: |
|
||||
Information specific to the runtime.
|
||||
|
||||
While this API specification does not define data provided by runtimes,
|
||||
the following well-known properties may be provided by runtimes:
|
||||
|
||||
`org.opencontainers.runtime-spec.features`: features structure as defined
|
||||
in the [OCI Runtime Specification](https://github.com/opencontainers/runtime-spec/blob/main/features.md),
|
||||
in a JSON string representation.
|
||||
|
||||
<p><br /></p>
|
||||
|
||||
> **Note**: The information returned in this field, including the
|
||||
> formatting of values and labels, should not be considered stable,
|
||||
> and may change without notice.
|
||||
type: "object"
|
||||
x-nullable: true
|
||||
additionalProperties:
|
||||
type: "string"
|
||||
example:
|
||||
"org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",\"ociVersionMax\":\"1.1.0\",\"...\":\"...\"}"
|
||||
|
||||
Commit:
|
||||
description: |
|
||||
|
|
|
@ -58,7 +58,7 @@ type Info struct {
|
|||
Labels []string
|
||||
ExperimentalBuild bool
|
||||
ServerVersion string
|
||||
Runtimes map[string]Runtime
|
||||
Runtimes map[string]RuntimeWithStatus
|
||||
DefaultRuntime string
|
||||
Swarm swarm.Info
|
||||
// LiveRestoreEnabled determines whether containers should be kept
|
||||
|
|
|
@ -12,3 +12,9 @@ type Runtime struct {
|
|||
Type string `json:"runtimeType,omitempty"`
|
||||
Options map[string]interface{} `json:"options,omitempty"`
|
||||
}
|
||||
|
||||
// RuntimeWithStatus extends [Runtime] to hold [RuntimeStatus].
|
||||
type RuntimeWithStatus struct {
|
||||
Runtime
|
||||
Status map[string]string `json:"status,omitempty"`
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package daemon // import "github.com/docker/docker/daemon"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -43,14 +44,22 @@ func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysI
|
|||
v.CPUSet = sysInfo.Cpuset
|
||||
v.PidsLimit = sysInfo.PidsLimit
|
||||
}
|
||||
v.Runtimes = make(map[string]system.Runtime)
|
||||
v.Runtimes = make(map[string]system.RuntimeWithStatus)
|
||||
for n, p := range stockRuntimes() {
|
||||
v.Runtimes[n] = system.Runtime{Path: p}
|
||||
v.Runtimes[n] = system.RuntimeWithStatus{
|
||||
Runtime: system.Runtime{
|
||||
Path: p,
|
||||
},
|
||||
Status: daemon.runtimeStatus(ctx, cfg, n),
|
||||
}
|
||||
}
|
||||
for n, r := range cfg.Config.Runtimes {
|
||||
v.Runtimes[n] = system.Runtime{
|
||||
Path: r.Path,
|
||||
Args: append([]string(nil), r.Args...),
|
||||
v.Runtimes[n] = system.RuntimeWithStatus{
|
||||
Runtime: system.Runtime{
|
||||
Path: r.Path,
|
||||
Args: append([]string(nil), r.Args...),
|
||||
},
|
||||
Status: daemon.runtimeStatus(ctx, cfg, n),
|
||||
}
|
||||
}
|
||||
v.DefaultRuntime = cfg.Runtimes.Default
|
||||
|
@ -486,3 +495,24 @@ func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version
|
|||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// ociRuntimeFeaturesKey is the "well-known" used for including the
|
||||
// OCI runtime spec "features" struct.
|
||||
//
|
||||
// see https://github.com/opencontainers/runtime-spec/blob/main/features.md
|
||||
const ociRuntimeFeaturesKey = "org.opencontainers.runtime-spec.features"
|
||||
|
||||
func (daemon *Daemon) runtimeStatus(ctx context.Context, cfg *configStore, runtimeName string) map[string]string {
|
||||
m := make(map[string]string)
|
||||
if runtimeName == "" {
|
||||
runtimeName = cfg.Runtimes.Default
|
||||
}
|
||||
if features := cfg.Runtimes.Features(runtimeName); features != nil {
|
||||
if j, err := json.Marshal(features); err == nil {
|
||||
m[ociRuntimeFeaturesKey] = string(j)
|
||||
} else {
|
||||
log.G(ctx).WithFields(log.Fields{"error": err, "runtime": runtimeName}).Warn("Failed to call json.Marshal for the OCI features struct of runtime")
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||
requests is now deprecated. You should instead use the field `TaskTemplate.Networks`.
|
||||
* The `Container` and `ContainerConfig` fields in the `GET /images/{name}/json`
|
||||
response are deprecated and will no longer be included in API v1.45.
|
||||
* `GET /info` now includes `status` properties in `Runtimes`.
|
||||
|
||||
## v1.43 API changes
|
||||
|
||||
|
|
Loading…
Reference in a new issue