فهرست منبع

Adding Platforms field to TaskSpec

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
Nishant Totla 8 سال پیش
والد
کامیت
1efbe6e876
4فایلهای تغییر یافته به همراه32 افزوده شده و 1 حذف شده
  1. 10 0
      api/swagger.yaml
  2. 5 0
      api/types/swarm/task.go
  3. 15 0
      daemon/cluster/convert/service.go
  4. 2 1
      docs/api/version-history.md

+ 10 - 0
api/swagger.yaml

@@ -2158,6 +2158,16 @@ definitions:
                     SpreadDescriptor:
                     SpreadDescriptor:
                       description: "label descriptor, such as engine.labels.az"
                       description: "label descriptor, such as engine.labels.az"
                       type: "string"
                       type: "string"
+          Platforms:
+            description: "An array of supported platforms."
+            type: "array"
+            items:
+              type: "object"
+              properties:
+                Architecture:
+                  type: "string"
+                OS:
+                  type: "string"
       ForceUpdate:
       ForceUpdate:
         description: "A counter that triggers an update even if no relevant parameters have been changed."
         description: "A counter that triggers an update even if no relevant parameters have been changed."
         type: "integer"
         type: "integer"

+ 5 - 0
api/types/swarm/task.go

@@ -88,6 +88,11 @@ type ResourceRequirements struct {
 type Placement struct {
 type Placement struct {
 	Constraints []string              `json:",omitempty"`
 	Constraints []string              `json:",omitempty"`
 	Preferences []PlacementPreference `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
 // PlacementPreference provides a way to make the scheduler aware of factors

+ 15 - 0
daemon/cluster/convert/service.go

@@ -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{
 		spec.Task.Placement = &swarmapi.Placement{
 			Constraints: s.TaskTemplate.Placement.Constraints,
 			Constraints: s.TaskTemplate.Placement.Constraints,
 			Preferences: preferences,
 			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
 	return r
 }
 }
 
 

+ 2 - 1
docs/api/version-history.md

@@ -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
 * `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
  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.
  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
 ## v1.29 API changes
 
 
@@ -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/(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`).
 * `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.
 * `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.
 * `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
 ## v1.28 API changes