Skip to content

Commit a91a492

Browse files
committed
consider swap checking memory in installer
Signed-off-by: Xichen Lin <[email protected]>
1 parent f0ce586 commit a91a492

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sonic_installer/main.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,10 @@ def __enter__(self):
460460
meminfo = self.read_from_meminfo()
461461
mem_total_in_bytes = meminfo["MemTotal"] * SWAPAllocator.KiB_TO_BYTES_FACTOR
462462
mem_avail_in_bytes = meminfo["MemAvailable"] * SWAPAllocator.KiB_TO_BYTES_FACTOR
463-
if (mem_total_in_bytes < self.total_mem_threshold * SWAPAllocator.MiB_TO_BYTES_FACTOR
464-
or mem_avail_in_bytes < self.available_mem_threshold * SWAPAllocator.MiB_TO_BYTES_FACTOR):
463+
swap_total_in_bytes = meminfo["SwapTotal"] * SWAPAllocator.KiB_TO_BYTES_FACTOR
464+
swap_free_in_bytes = meminfo["SwapFree"] * SWAPAllocator.KiB_TO_BYTES_FACTOR
465+
if (mem_total_in_bytes + swap_total_in_bytes < self.total_mem_threshold * SWAPAllocator.MiB_TO_BYTES_FACTOR
466+
or mem_avail_in_bytes + swap_free_in_bytes < self.available_mem_threshold * SWAPAllocator.MiB_TO_BYTES_FACTOR):
465467
echo_and_log("Setup SWAP memory")
466468
swapfile = SWAPAllocator.SWAP_FILE_PATH
467469
if os.path.exists(swapfile):

0 commit comments

Comments
 (0)