mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 05:37:53 +00:00
Get image name from DB when getting the app current state
The Service class in `compose/service.ts` cannot get the image name from the image id when building the object from the container metadata. We query the metadata in the application manager getCurrentApps method so the current state can be used as target by API methods Change-type: patch
This commit is contained in:
parent
27f0d2e655
commit
b1fc4e1761
@ -316,6 +316,8 @@ export async function getCurrentApps(): Promise<InstancedAppState> {
|
||||
await volumeManager.getAll(),
|
||||
);
|
||||
|
||||
const images = await imageManager.getState();
|
||||
|
||||
const apps: InstancedAppState = {};
|
||||
for (const strAppId of Object.keys(componentGroups)) {
|
||||
const appId = parseInt(strAppId, 10);
|
||||
@ -341,12 +343,23 @@ export async function getCurrentApps(): Promise<InstancedAppState> {
|
||||
!_.isEmpty(components.volumes) ||
|
||||
!_.isEmpty(components.networks)
|
||||
) {
|
||||
const services = componentGroups[appId].services.map((s) => {
|
||||
// We get the image metadata from the image database because we cannot
|
||||
// get it from the container itself
|
||||
const imageForService = images.find(
|
||||
(img) => img.serviceName === s.serviceName && img.commit === s.commit,
|
||||
);
|
||||
|
||||
s.imageName = imageForService?.name ?? s.imageName;
|
||||
return s;
|
||||
});
|
||||
|
||||
apps[appId] = new App(
|
||||
{
|
||||
appId,
|
||||
appUuid: uuid,
|
||||
commit,
|
||||
services: componentGroups[appId].services,
|
||||
services,
|
||||
networks: componentGroups[appId].networks,
|
||||
volumes: componentGroups[appId].volumes,
|
||||
},
|
||||
@ -496,7 +509,6 @@ export async function executeStep(
|
||||
} as any);
|
||||
}
|
||||
|
||||
// FIXME: This shouldn't be in this module
|
||||
export async function setTarget(
|
||||
apps: TargetApps,
|
||||
source: string,
|
||||
|
Loading…
Reference in New Issue
Block a user