diff --git a/src/host-config.ts b/src/host-config.ts index c7cbc492..cb0882da 100644 --- a/src/host-config.ts +++ b/src/host-config.ts @@ -5,6 +5,7 @@ import { promises as fs } from 'fs'; import * as path from 'path'; import * as config from './config'; +import * as applicationManager from './compose/application-manager'; import * as constants from './lib/constants'; import * as dbus from './lib/dbus'; import { ENOENT, InternalInconsistencyError } from './lib/errors'; @@ -217,12 +218,13 @@ export function get(): Bluebird { } export async function patch(conf: HostConfig, force: boolean): Promise { - const appId = await config.get('applicationId'); - if (!appId) { + const apps = await applicationManager.getCurrentApps(); + const appIds = Object.keys(apps).map((strId) => parseInt(strId, 10)); + if (!appIds.length) { throw new InternalInconsistencyError('Could not find an appId'); } - return updateLock.lock(appId, { force }, () => { + return updateLock.lock(appIds, { force }, () => { const promises: Array> = []; if (conf != null && conf.network != null) { if (conf.network.proxy != null) { diff --git a/test/41-device-api-v1.spec.ts b/test/41-device-api-v1.spec.ts index 8fd7da5d..3e9f3f22 100644 --- a/test/41-device-api-v1.spec.ts +++ b/test/41-device-api-v1.spec.ts @@ -31,10 +31,11 @@ import * as targetStateCache from '../src/device-state/target-state-cache'; import blink = require('../src/lib/blink'); import constants = require('../src/lib/constants'); import * as deviceAPI from '../src/device-api/common'; - import { UpdatesLockedError } from '../src/lib/errors'; import { SchemaTypeKey } from '../src/config/schema-type'; import log from '../src/lib/supervisor-console'; +import * as applicationManager from '../src/compose/application-manager'; +import App from '../src/compose/app'; describe('SupervisorAPI [V1 Endpoints]', () => { let api: SupervisorAPI; @@ -937,11 +938,23 @@ describe('SupervisorAPI [V1 Endpoints]', () => { before(() => { configSetStub = stub(config, 'set').callsFake(configSetFakeFn); logWarnStub = stub(log, 'warn'); + stub(applicationManager, 'getCurrentApps').resolves({ + '1234567': new App( + { + appId: 1234567, + services: [], + volumes: {}, + networks: {}, + }, + false, + ), + }); }); after(() => { configSetStub.restore(); logWarnStub.restore(); + (applicationManager.getCurrentApps as SinonStub).restore(); }); beforeEach(() => {