Fix: Access container memory_stats.stats safely by optional chaining (#2271) (#2272)

pull/2281/head
Ingmar Delsink 1 year ago committed by GitHub
parent ebd384c62d
commit 67f5ee8df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,6 @@ export function calculateCPUPercent(stats) {
export function calculateUsedMemory(stats) { export function calculateUsedMemory(stats) {
// see https://github.com/docker/cli/blob/dcc161076861177b5eef6cb321722520db3184e7/cli/command/container/stats_helpers.go#L239 // see https://github.com/docker/cli/blob/dcc161076861177b5eef6cb321722520db3184e7/cli/command/container/stats_helpers.go#L239
return ( return (
stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats.inactive_file ?? 0) stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats?.inactive_file ?? 0)
); );
} }

Loading…
Cancel
Save