Skip to content

Commit

Permalink
Adding Platforms field to TaskSpec
Browse files Browse the repository at this point in the history
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
  • Loading branch information
nishanttotla committed May 15, 2017
1 parent 4dbea10 commit 1efbe6e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
10 changes: 10 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,16 @@ definitions:
SpreadDescriptor:
description: "label descriptor, such as engine.labels.az"
type: "string"
Platforms:
description: "An array of supported platforms."
type: "array"
items:
type: "object"
properties:
Architecture:
type: "string"
OS:
type: "string"
ForceUpdate:
description: "A counter that triggers an update even if no relevant parameters have been changed."
type: "integer"
Expand Down
5 changes: 5 additions & 0 deletions api/types/swarm/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ type ResourceRequirements struct {
type Placement struct {
Constraints []string `json:",omitempty"`
Preferences []PlacementPreference `json:",omitempty"`

// Platforms stores all the platforms that the image can run on.
// This field is used in the platform filter for scheduling. If empty,
// then the platform filter is off, meaning there are no scheduling restrictions.
Platforms []Platform `json:",omitempty"`
}

// PlacementPreference provides a way to make the scheduler aware of factors
Expand Down
15 changes: 15 additions & 0 deletions daemon/cluster/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,17 @@ func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
})
}
}
var platforms []*swarmapi.Platform
for _, plat := range s.TaskTemplate.Placement.Platforms {
platforms = append(platforms, &swarmapi.Platform{
Architecture: plat.Architecture,
OS: plat.OS,
})
}
spec.Task.Placement = &swarmapi.Placement{
Constraints: s.TaskTemplate.Placement.Constraints,
Preferences: preferences,
Platforms: platforms,
}
}

Expand Down Expand Up @@ -393,6 +401,13 @@ func placementFromGRPC(p *swarmapi.Placement) *types.Placement {
}
}

for _, plat := range p.Platforms {
r.Platforms = append(r.Platforms, types.Platform{
Architecture: plat.Architecture,
OS: plat.OS,
})
}

return r
}

Expand Down
3 changes: 2 additions & 1 deletion docs/api/version-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ keywords: "API, Docker, rcli, REST, documentation"
* `POST /swarm/update` now accepts 3 additional parameters as part of the swarm spec's CA configuration; the desired CA certificate for
the swarm, the desired CA key for the swarm (if not using an external certificate), and an optional parameter to force swarm to
generate and rotate to a new CA certificate/key pair.
* `POST /service/create` and `POST /services/(id or name)/update` now take the field `Platforms` as part of the service `Placement`, allowing to specify platforms supported by the service.

## v1.29 API changes

Expand All @@ -37,7 +38,7 @@ keywords: "API, Docker, rcli, REST, documentation"
* `GET /networks/(name)` now returns an `Ingress` field showing whether the network is the ingress one.
* `GET /networks/` now supports a `scope` filter to filter networks based on the network mode (`swarm`, `global`, or `local`).
* `POST /containers/create`, `POST /service/create` and `POST /services/(id or name)/update` now takes the field `StartPeriod` as a part of the `HealthConfig` allowing for specification of a period during which the container should not be considered unhealthy even if health checks do not pass.
* `GET /services/(id)` now accepts an `insertDefaults` query-parameter to merge default values into the service inspect output.
* `GET /services/(id)` now accepts an `insertDefaults` query-parameter to merge default values into the service inspect output.
* `POST /containers/prune`, `POST /images/prune`, `POST /volumes/prune`, and `POST /networks/prune` now support a `label` filter to filter containers, images, volumes, or networks based on the label. The format of the label filter could be `label=<key>`/`label=<key>=<value>` to remove those with the specified labels, or `label!=<key>`/`label!=<key>=<value>` to remove those without the specified labels.

## v1.28 API changes
Expand Down

0 comments on commit 1efbe6e

Please sign in to comment.