Merge pull request #33144 from nishanttotla/update-swarmkit-platform-structs

Adding Platforms field to TaskSpec Placement
This commit is contained in:
Brian Goff 2017-05-16 15:22:03 -04:00 committed by GitHub
commit 7b7f9a481e
4 changed files with 32 additions and 1 deletions

View File

@ -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"

View File

@ -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

View File

@ -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,
}
}
@ -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
}

View File

@ -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