Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ignore swapfile entries during post-update persist files handling #305

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions otaclient/app/ota_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down
Loading