From b8edc509f88709b83a72b741d091e9a410a10afc Mon Sep 17 00:00:00 2001 From: Bodong Yang <86948717+Bodong-Yang@users.noreply.github.com> Date: Mon, 20 May 2024 11:31:58 +0900 Subject: [PATCH] refactor: ignore swapfile entries during post-update persist files handling (#305) This PR makes otaclient ignores swapfile entries(/swapfile, /swap.img) during post OTA update persist file handling. --- otaclient/app/ota_client.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/otaclient/app/ota_client.py b/otaclient/app/ota_client.py index 17b104b7a..fa7eed016 100644 --- a/otaclient/app/ota_client.py +++ b/otaclient/app/ota_client.py @@ -29,9 +29,6 @@ from typing import Iterator, Optional, Type from urllib.parse import urlparse -from otaclient._utils import get_file_size -from otaclient._utils.linux import create_swapfile - from . import downloader from . import errors as ota_errors from . import ota_metadata @@ -311,22 +308,19 @@ def _process_persistents(self): ): _per_fpath = Path(_perinf.path) - # NOTE(20240220): fast fix for handling swapfile + # NOTE(20240520): with update_swapfile ansible role being used wildly, + # now we just ignore the swapfile entries in the persistents.txt if any, + # and issue a warning about it. if str(_per_fpath) in ["/swapfile", "/swap.img"]: - # NOTE: here we probe the current running system's swapfile at /. - if not _per_fpath.is_file(): - continue - - _new_swapfile = standby_slot_mp / _per_fpath.relative_to("/") - try: - _swapfile_size = get_file_size(_per_fpath, units="MiB") - assert _swapfile_size is not None, f"{_per_fpath} doesn't exist" - create_swapfile(_new_swapfile, _swapfile_size) - logger.warning(f"create {_new_swapfile} with {_swapfile_size=}") - except Exception as e: - logger.warning( - f"failed to create swapfile {_per_fpath} to standby slot, skip: {e!r}" + logger.warning( + f"swapfile entry {_per_fpath} is listed in persistents.txt, ignored" + ) + logger.warning( + ( + "using persis file feature to preserve swapfile is MISUSE of persist file handling feature!" + "please change your OTA image build setting and remove swapfile entries from persistents.txt!" ) + ) continue if (