Merge pull request #33440 from RenaudWasTaken/genericresource
Added support for Generic Resources Upstream-commit: 9319a8a2dd5760b3d0eda359b8c3872f5e37aa87 Component: engine
This commit is contained in:
@@ -487,6 +487,41 @@ definitions:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
|
||||
ResourceObject:
|
||||
description: "An object describing the resources which can be advertised by a node and requested by a task"
|
||||
type: "object"
|
||||
properties:
|
||||
NanoCPUs:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
MemoryBytes:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
GenericResources:
|
||||
$ref: "#/definitions/GenericResources"
|
||||
|
||||
GenericResources:
|
||||
description: "User defined Resources, can be either Integer resources (e.g: SSD=3) or String resources (e.g: GPU={UUID1, UUID2})"
|
||||
type: "array"
|
||||
items:
|
||||
type: "object"
|
||||
properties:
|
||||
NamedResourceSpec:
|
||||
type: "object"
|
||||
properties:
|
||||
Kind:
|
||||
type: "string"
|
||||
Value:
|
||||
type: "string"
|
||||
DiscreteResourceSpec:
|
||||
type: "object"
|
||||
properties:
|
||||
Kind:
|
||||
type: "string"
|
||||
Value:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
|
||||
HealthConfig:
|
||||
description: "A test to perform to check that the container is healthy."
|
||||
type: "object"
|
||||
@@ -1712,14 +1747,7 @@ definitions:
|
||||
OS:
|
||||
type: "string"
|
||||
Resources:
|
||||
type: "object"
|
||||
properties:
|
||||
NanoCPUs:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
MemoryBytes:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
$ref: "#/definitions/ResourceObject"
|
||||
Engine:
|
||||
type: "object"
|
||||
properties:
|
||||
@@ -1760,6 +1788,16 @@ definitions:
|
||||
Resources:
|
||||
NanoCPUs: 4000000000
|
||||
MemoryBytes: 8272408576
|
||||
GenericResources:
|
||||
- DiscreteResourceSpec:
|
||||
Kind: "SSD"
|
||||
Value: 3
|
||||
- NamedResourceSpec:
|
||||
Kind: "GPU"
|
||||
Value: "UUID1"
|
||||
- NamedResourceSpec:
|
||||
Kind: "GPU"
|
||||
Value: "UUID2"
|
||||
Engine:
|
||||
EngineVersion: "17.04.0"
|
||||
Labels:
|
||||
@@ -2224,27 +2262,10 @@ definitions:
|
||||
properties:
|
||||
Limits:
|
||||
description: "Define resources limits."
|
||||
type: "object"
|
||||
properties:
|
||||
NanoCPUs:
|
||||
description: "CPU limit in units of 10<sup>-9</sup> CPU shares."
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
MemoryBytes:
|
||||
description: "Memory limit in Bytes."
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
$ref: "#/definitions/ResourceObject"
|
||||
Reservation:
|
||||
description: "Define resources reservation."
|
||||
properties:
|
||||
NanoCPUs:
|
||||
description: "CPU reservation in units of 10<sup>-9</sup> CPU shares."
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
MemoryBytes:
|
||||
description: "Memory reservation in Bytes."
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
$ref: "#/definitions/ResourceObject"
|
||||
RestartPolicy:
|
||||
description: "Specification for the restart policy which applies to containers created as part of this service."
|
||||
type: "object"
|
||||
@@ -2375,6 +2396,8 @@ definitions:
|
||||
NodeID:
|
||||
description: "The ID of the node that this task is on."
|
||||
type: "string"
|
||||
AssignedGenericResources:
|
||||
$ref: "#/definitions/GenericResources"
|
||||
Status:
|
||||
type: "object"
|
||||
properties:
|
||||
@@ -2454,6 +2477,16 @@ definitions:
|
||||
Gateway: "10.255.0.1"
|
||||
Addresses:
|
||||
- "10.255.0.10/16"
|
||||
AssignedGenericResources:
|
||||
- DiscreteResourceSpec:
|
||||
Kind: "SSD"
|
||||
Value: 3
|
||||
- NamedResourceSpec:
|
||||
Kind: "GPU"
|
||||
Value: "UUID1"
|
||||
- NamedResourceSpec:
|
||||
Kind: "GPU"
|
||||
Value: "UUID2"
|
||||
ServiceSpec:
|
||||
description: "User modifiable configuration for a service."
|
||||
properties:
|
||||
@@ -5516,6 +5549,8 @@ paths:
|
||||
type: "string"
|
||||
MemTotal:
|
||||
type: "integer"
|
||||
GenericResources:
|
||||
$ref: "#/definitions/GenericResources"
|
||||
MemoryLimit:
|
||||
type: "boolean"
|
||||
NCPU:
|
||||
|
||||
@@ -51,6 +51,7 @@ type Task struct {
|
||||
Status TaskStatus `json:",omitempty"`
|
||||
DesiredState TaskState `json:",omitempty"`
|
||||
NetworksAttachments []NetworkAttachment `json:",omitempty"`
|
||||
GenericResources []GenericResource `json:",omitempty"`
|
||||
}
|
||||
|
||||
// TaskSpec represents the spec of a task.
|
||||
@@ -79,8 +80,34 @@ type TaskSpec struct {
|
||||
|
||||
// Resources represents resources (CPU/Memory).
|
||||
type Resources struct {
|
||||
NanoCPUs int64 `json:",omitempty"`
|
||||
MemoryBytes int64 `json:",omitempty"`
|
||||
NanoCPUs int64 `json:",omitempty"`
|
||||
MemoryBytes int64 `json:",omitempty"`
|
||||
GenericResources []GenericResource `json:",omitempty"`
|
||||
}
|
||||
|
||||
// GenericResource represents a "user defined" resource which can
|
||||
// be either an integer (e.g: SSD=3) or a string (e.g: SSD=sda1)
|
||||
type GenericResource struct {
|
||||
NamedResourceSpec *NamedGenericResource `json:",omitempty"`
|
||||
DiscreteResourceSpec *DiscreteGenericResource `json:",omitempty"`
|
||||
}
|
||||
|
||||
// NamedGenericResource represents a "user defined" resource which is defined
|
||||
// as a string.
|
||||
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
|
||||
// Value is used to identify the resource (GPU="UUID-1", FPGA="/dev/sdb5", ...)
|
||||
type NamedGenericResource struct {
|
||||
Kind string `json:",omitempty"`
|
||||
Value string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// DiscreteGenericResource represents a "user defined" resource which is defined
|
||||
// as an integer
|
||||
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
|
||||
// Value is used to count the resource (SSD=5, HDD=3, ...)
|
||||
type DiscreteGenericResource struct {
|
||||
Kind string `json:",omitempty"`
|
||||
Value int64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ResourceRequirements represents resources requirements.
|
||||
|
||||
@@ -168,6 +168,7 @@ type Info struct {
|
||||
RegistryConfig *registry.ServiceConfig
|
||||
NCPU int
|
||||
MemTotal int64
|
||||
GenericResources []swarm.GenericResource
|
||||
DockerRootDir string
|
||||
HTTPProxy string `json:"HttpProxy"`
|
||||
HTTPSProxy string `json:"HttpsProxy"`
|
||||
|
||||
Reference in New Issue
Block a user