mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
NRI: include in API Info response
Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
@@ -13,6 +13,11 @@ keywords: "API, Docker, rcli, REST, documentation"
|
||||
will be rejected.
|
||||
-->
|
||||
|
||||
## v1.53 API changes
|
||||
|
||||
* `GET /info` now includes an `NRI` field. If the Node Resource Interface (NRI)
|
||||
is enabled, this field contains information describing it.
|
||||
|
||||
## v1.52 API changes
|
||||
|
||||
* `GET /images/{name}/get` now accepts multiple `platform` query-arguments
|
||||
|
||||
@@ -2943,6 +2943,31 @@ definitions:
|
||||
The unique identifier for the device within its source driver.
|
||||
For CDI devices, this would be an FQDN like "vendor.com/gpu=0".
|
||||
|
||||
NRIInfo:
|
||||
description: |
|
||||
Information about the Node Resource Interface (NRI).
|
||||
|
||||
This field is only present if NRI is enabled.
|
||||
type: "object"
|
||||
x-nullable: true
|
||||
properties:
|
||||
Info:
|
||||
description: |
|
||||
Information about NRI, provided as "label" / "value" pairs.
|
||||
|
||||
<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: "array"
|
||||
items:
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
example:
|
||||
- ["plugin-path", "/opt/docker/nri/plugins"]
|
||||
|
||||
ErrorDetail:
|
||||
type: "object"
|
||||
properties:
|
||||
@@ -6980,6 +7005,8 @@ definitions:
|
||||
type: "array"
|
||||
items:
|
||||
$ref: "#/definitions/DeviceInfo"
|
||||
NRI:
|
||||
$ref: "#/definitions/NRIInfo"
|
||||
Warnings:
|
||||
description: |
|
||||
List of warnings / informational messages about missing features, or
|
||||
|
||||
@@ -2946,6 +2946,31 @@ definitions:
|
||||
The unique identifier for the device within its source driver.
|
||||
For CDI devices, this would be an FQDN like "vendor.com/gpu=0".
|
||||
|
||||
NRIInfo:
|
||||
description: |
|
||||
Information about the Node Resource Interface (NRI).
|
||||
|
||||
This field is only present if NRI is enabled.
|
||||
type: "object"
|
||||
x-nullable: true
|
||||
properties:
|
||||
Info:
|
||||
description: |
|
||||
Information about NRI, provided as "label" / "value" pairs.
|
||||
|
||||
<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: "array"
|
||||
items:
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
example:
|
||||
- ["plugin-path", "/opt/docker/nri/plugins"]
|
||||
|
||||
ErrorDetail:
|
||||
type: "object"
|
||||
properties:
|
||||
@@ -6983,6 +7008,8 @@ definitions:
|
||||
type: "array"
|
||||
items:
|
||||
$ref: "#/definitions/DeviceInfo"
|
||||
NRI:
|
||||
$ref: "#/definitions/NRIInfo"
|
||||
Warnings:
|
||||
description: |
|
||||
List of warnings / informational messages about missing features, or
|
||||
|
||||
@@ -74,6 +74,7 @@ type Info struct {
|
||||
FirewallBackend *FirewallInfo `json:"FirewallBackend,omitempty"`
|
||||
CDISpecDirs []string
|
||||
DiscoveredDevices []DeviceInfo `json:",omitempty"`
|
||||
NRI *NRIInfo `json:",omitempty"`
|
||||
|
||||
Containerd *ContainerdInfo `json:",omitempty"`
|
||||
|
||||
@@ -163,3 +164,8 @@ type DeviceInfo struct {
|
||||
// Example: CDI FQDN like "vendor.com/gpu=0", or other driver-specific device ID
|
||||
ID string `json:"ID"`
|
||||
}
|
||||
|
||||
// NRIInfo describes the NRI configuration.
|
||||
type NRIInfo struct {
|
||||
Info [][2]string `json:"Info,omitempty"`
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ func (daemon *Daemon) SystemInfo(ctx context.Context) (*system.Info, error) {
|
||||
LiveRestoreEnabled: cfg.LiveRestoreEnabled,
|
||||
Isolation: daemon.defaultIsolation,
|
||||
CDISpecDirs: promoteNil(cfg.CDISpecDirs),
|
||||
NRI: daemon.nri.GetInfo(),
|
||||
}
|
||||
|
||||
daemon.fillContainerStates(v)
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
nrilog "github.com/containerd/nri/pkg/log"
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/mount"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/rootless"
|
||||
"github.com/moby/moby/v2/daemon/pkg/opts"
|
||||
@@ -91,6 +92,25 @@ func NewNRI(ctx context.Context, cfg Config) (*NRI, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// GetInfo returns status for inclusion in the system info API.
|
||||
func (n *NRI) GetInfo() *system.NRIInfo {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
n.mu.RLock()
|
||||
defer n.mu.RUnlock()
|
||||
if n.adap == nil {
|
||||
return nil
|
||||
}
|
||||
info := system.NRIInfo{}
|
||||
info.Info = append(info.Info, [2]string{"plugin-path", n.cfg.DaemonConfig.PluginPath})
|
||||
info.Info = append(info.Info, [2]string{"plugin-config-path", n.cfg.DaemonConfig.PluginConfigPath})
|
||||
if n.cfg.DaemonConfig.SocketPath != "" {
|
||||
info.Info = append(info.Info, [2]string{"socket-path", n.cfg.DaemonConfig.SocketPath})
|
||||
}
|
||||
return &info
|
||||
}
|
||||
|
||||
// Shutdown stops the NRI instance and releases its resources.
|
||||
func (n *NRI) Shutdown(ctx context.Context) {
|
||||
n.mu.Lock()
|
||||
|
||||
@@ -118,6 +118,10 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
|
||||
"BridgeNfIp6tables": json.RawMessage("false"),
|
||||
}))
|
||||
}
|
||||
if versions.LessThan(version, "1.53") {
|
||||
// Field introduced in API v1.53.
|
||||
info.NRI = nil
|
||||
}
|
||||
return compat.Wrap(info, legacyOptions...), nil
|
||||
})
|
||||
|
||||
|
||||
6
vendor/github.com/moby/moby/api/types/system/info.go
generated
vendored
6
vendor/github.com/moby/moby/api/types/system/info.go
generated
vendored
@@ -74,6 +74,7 @@ type Info struct {
|
||||
FirewallBackend *FirewallInfo `json:"FirewallBackend,omitempty"`
|
||||
CDISpecDirs []string
|
||||
DiscoveredDevices []DeviceInfo `json:",omitempty"`
|
||||
NRI *NRIInfo `json:",omitempty"`
|
||||
|
||||
Containerd *ContainerdInfo `json:",omitempty"`
|
||||
|
||||
@@ -163,3 +164,8 @@ type DeviceInfo struct {
|
||||
// Example: CDI FQDN like "vendor.com/gpu=0", or other driver-specific device ID
|
||||
ID string `json:"ID"`
|
||||
}
|
||||
|
||||
// NRIInfo describes the NRI configuration.
|
||||
type NRIInfo struct {
|
||||
Info [][2]string `json:"Info,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user