mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Don't use config.get for appId when checking locks in host config PATCH
Change-type: patch Signed-off-by: Christina Wang <christina@balena.io>
This commit is contained in:
parent
d9186649a6
commit
be1c01039a
@ -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<HostConfig> {
|
||||
}
|
||||
|
||||
export async function patch(conf: HostConfig, force: boolean): Promise<void> {
|
||||
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<Promise<void>> = [];
|
||||
if (conf != null && conf.network != null) {
|
||||
if (conf.network.proxy != null) {
|
||||
|
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user