Fix gpu label support

The device request object was created with untouched fields left unset. When
comparing state to determine if a transition is required this would
result in a mismatch between:

    {
      Driver: '',
      Count: 1,
      DeviceIDs: null,
      Capabilities: [Array],
      Options: null
    }

and

    {
      Count: 1,
      Capabilities: [Array],
    }

Which in turn resulted in the target service being continously restarted.
The fix is to instantiate the object in full.

Connects-to: https://github.com/balena-io/balena-supervisor/issues/1449
Connects-to: ae646a07ec
Change-type: patch
Signed-off-by: Robert Günzler <robertg@balena.io>
This commit is contained in:
Robert Günzler 2021-01-28 12:59:22 +01:00
parent 432b1dbcc5
commit f009d3a3e9
No known key found for this signature in database
GPG Key ID: 2143BD2AAB94BCC4
2 changed files with 6 additions and 0 deletions

View File

@ -402,8 +402,11 @@ export async function addFeaturesFromLabels(
// bahavior of docker cli
// https://github.com/balena-os/balena-engine-cli/blob/19.03-balena/opts/gpus.go#L81-L89
service.config.deviceRequests.push({
Driver: '',
Count: 1,
DeviceIDs: [],
Capabilities: [['gpu']],
Options: {},
} as Dockerode.DeviceRequest),
};

View File

@ -503,8 +503,11 @@ describe('compose/service', () => {
describe('io.balena.features.gpu: Docker <-> Compose config', () => {
const gpuDeviceRequest = {
Driver: '',
DeviceIDs: [],
Count: 1,
Capabilities: [['gpu']],
Options: {},
};
it('should succeed from compose object', async () => {
const s = await Service.fromComposeObject(