presidium 0.26.6 → 0.26.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Archive.test.js CHANGED
@@ -36,7 +36,7 @@ const test = new Test('Archive', Archive)
36
36
  })
37
37
 
38
38
  .case({
39
- Dockerfile: 'FROM busybox:1.32'
39
+ Dockerfile: 'FROM busybox:1.32',
40
40
  '.aws/credentials': '[claimyr]\naccessKeyId\nsecretAccessKey',
41
41
  }, async archive => {
42
42
  const pack = await archive.tar(`${pathResolve(__dirname, 'internal')}/`, {
package/Docker.js CHANGED
@@ -328,6 +328,7 @@ Docker.prototype.removeImage = function dockerRemoveImage(image, options) {
328
328
  * healthStartPeriod: >=1e6, // nanoseconds to wait on container init before starting first healthcheck
329
329
  * memory: number, // memory limit in bytes
330
330
  * cpus: number, // number of cpus
331
+ * gpus?: 'all', // expose gpus
331
332
  * mounts: Array<{
332
333
  * source: string, // name of volume
333
334
  * target: string, // mounted path inside container
@@ -468,6 +469,7 @@ Docker.prototype.createContainer = function dockerCreateContainer(
468
469
  })(options.restart.split(':')),
469
470
  },
470
471
  ...options.rm && { AutoRemove: options.rm },
472
+
471
473
  },
472
474
  }),
473
475
 
@@ -634,6 +636,9 @@ Docker.prototype.joinSwarm = async function dockerJoinSwarm(
634
636
  address, token, options = {}
635
637
  ) {
636
638
  return this.http.post('/swarm/join', {
639
+ headers: {
640
+ 'Content-Type': 'application/json',
641
+ },
637
642
  body: stringifyJSON({
638
643
  JoinToken: token,
639
644
  AdvertiseAddr: get('advertiseAddr', address)(options),
@@ -868,6 +873,15 @@ Docker.prototype.createService = function dockerCreateService(service, options)
868
873
  ...options.cpus ? {
869
874
  NanoCPUs: Number(options.cpus * 1e9),
870
875
  } : {},
876
+
877
+ ...options.gpus == 'all' ? {
878
+ GenericResources: [{
879
+ DiscreteResourceSpec: {
880
+ Kind: 'gpu',
881
+ Value: 1,
882
+ },
883
+ }],
884
+ } : {},
871
885
  }, // bytes
872
886
  },
873
887
 
package/Docker.test.js CHANGED
@@ -335,6 +335,7 @@ EXPOSE 8888`,
335
335
  }],
336
336
  memory: 512e6, // bytes
337
337
  cpus: 2,
338
+ gpus: 'all',
338
339
  restart: 'on-failure:5',
339
340
 
340
341
  healthCmd: ['wget', '--no-verbose', '--tries=1', '--spider', 'localhost:3000'],
@@ -364,6 +365,10 @@ EXPOSE 8888`,
364
365
  assert.equal(data.Spec.Labels.foo, 'bar')
365
366
  assert.equal(data.Spec.TaskTemplate.Resources.Reservations.NanoCPUs, 2000000000)
366
367
  assert.equal(data.Spec.TaskTemplate.Resources.Reservations.MemoryBytes, 512000000)
368
+ assert.equal(
369
+ data.Spec.TaskTemplate.Resources.Reservations.GenericResources[0].DiscreteResourceSpec.Kind,
370
+ 'gpu',
371
+ )
367
372
  })
368
373
 
369
374
  this.serviceId1 = serviceId
package/DockerService.js CHANGED
@@ -26,7 +26,7 @@ const dockerServiceOptions = [
26
26
  'rollbackParallelism', 'rollbackDelay',
27
27
  'rollbackFailureAction', 'rollbackMonitor', 'rollbackMaxFailureRatio',
28
28
  'username', 'password', 'email', 'serveraddress', 'identitytoken',
29
- 'network', 'memory', 'cpus',
29
+ 'network', 'memory', 'cpus', 'gpus',
30
30
  'force',
31
31
  ]
32
32
 
@@ -130,7 +130,7 @@ const createUpdateServiceSpec = function (options) {
130
130
  if (options.restartDelay != null) {
131
131
  result.TaskTemplate.RestartPolicy.Delay = Number(options.restartDelay)
132
132
  }
133
- if (or([has('memory'), has('cpus')])(options)) {
133
+ if (or(options, [has('memory'), has('cpus'), has('gpus')])) {
134
134
  result.TaskTemplate.Resources = {}
135
135
  result.TaskTemplate.Resources.Reservations = {}
136
136
  result.TaskTemplate.Resources.Limits = {}
@@ -147,6 +147,15 @@ const createUpdateServiceSpec = function (options) {
147
147
  result.TaskTemplate.Resources.Limits.NanoCPUs =
148
148
  Number(options.cpus * 1e9)
149
149
  }
150
+ if (options.gpus != null) {
151
+ result.TaskTemplate.Resources.Reservations.GenericResources = []
152
+ result.TaskTemplate.Resources.Reservations.GenericResources.push({
153
+ DiscreteResourceSpec: {
154
+ Kind: 'gpu',
155
+ Value: 1,
156
+ },
157
+ })
158
+ }
150
159
  if (or([has('logDriver'), has('logDriverOptions')])(options)) {
151
160
  result.TaskTemplate.LogDriver = {}
152
161
  }
@@ -241,6 +241,29 @@ const test = new Test('createUpdateServiceSpec', createUpdateServiceSpec)
241
241
  },
242
242
  })
243
243
 
244
+ .case({
245
+ serviceName: 'my-service',
246
+ spec: {
247
+ TaskTemplate: {},
248
+ },
249
+ gpus: 'all',
250
+ }, {
251
+ Name: 'my-service',
252
+ TaskTemplate: {
253
+ Resources: {
254
+ Limits: {},
255
+ Reservations: {
256
+ GenericResources: [{
257
+ DiscreteResourceSpec: {
258
+ Kind: 'gpu',
259
+ Value: 1,
260
+ },
261
+ }],
262
+ },
263
+ },
264
+ },
265
+ })
266
+
244
267
  .case({
245
268
  serviceName: 'my-service',
246
269
  spec: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.26.6",
3
+ "version": "0.26.8",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",