Fix crash when accessing memory_stats

This commit is contained in:
Girish Ramakrishnan
2022-11-24 00:40:40 +01:00
parent 4c6f7de10a
commit 9477e0bbb5
2 changed files with 13 additions and 8 deletions

View File

@@ -133,9 +133,11 @@ async function status() {
? (container.HostConfig.ReadonlyRootfs ? services.SERVICE_STATUS_ACTIVE : services.SERVICE_STATUS_STARTING)
: services.SERVICE_STATUS_STOPPED;
const stats = result.memory_stats || { usage: 0, limit: 1 };
return {
status,
memoryUsed: result.memory_stats.usage,
memoryPercent: parseInt(100 * result.memory_stats.usage / result.memory_stats.limit)
memoryUsed: stats.usage,
memoryPercent: parseInt(100 * stats.usage / stats.limit)
};
}