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

fix(v3.6.x): properly handling swapfile during persist file handling #275

Merged
merged 6 commits into from
Mar 4, 2024

Conversation

Bodong-Yang
Copy link
Member

@Bodong-Yang Bodong-Yang commented Feb 20, 2024

Description

This PR implements the proper way to create swapfile, and provides a workaround fix in persist file handling to handle swapfile creating.

At the time when persist file mechanism design was proposed by the original developer, handling swapfile was not considered but is wildly used in real world to create swapfile in new slot.
By default direct copy is used to persist file from active slot to standby slot, however for swapfile, direct copy is improper(see https://wiki.archlinux.org/title/swap for the proper way of creating a swapfile) and will cost unnecessary time if the swapfile is huge.

Note

In the upcoming new OTA image spec, we will no-longer handle swapfile in persist file handling hook, but handle it at dedicated hook.

Check list

  • test file that covers the bug case(s) is implemented.
  • local test is passed.

Bug fix

Behaivor after fix

  1. persist file handling(in PROCESS_POSTUPDATE phase) will not take long time if swapfile is huge.
  2. swapfile is created by proper method.

Related links & ticket

RT4-8553

Copy link
Contributor

github-actions bot commented Feb 20, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
otaclient/app
   __init__.py00100% 
   __main__.py330%16–19
   common.py2681495%55, 185, 200, 275–277, 287, 296–298, 404, 416, 535–539
   configs.py760100% 
   copy_tree.py81396%45, 96, 125
   downloader.py2714484%70, 83–84, 299, 304, 308, 326–327, 377–381, 400–410, 431–449, 458, 533–535, 551, 571–589
   ecu_info.py59788%78–79, 92, 97, 120–121, 130
   errors.py1130100% 
   interface.py17476%32, 43, 47, 51
   log_setting.py26773%27–28, 55–65
   main.py31294%43–44
   ota_client.py39714863%54–55, 77, 183–207, 244–247, 259–275, 285–288, 294–326, 368–371, 376–383, 396–419, 425–428, 457–481, 495–502, 509, 512–518, 565–568, 576, 612, 617–639, 700–716, 727–743, 754, 773, 784–785, 802, 821, 825–826, 841
   ota_client_call.py38684%42–44, 80–82
   ota_client_service.py29390%58–60
   ota_client_stub.py39510873%79–84, 92–102, 106–128, 133–142, 145–152, 160–165, 207–209, 214, 249, 274, 277, 280, 384, 410, 412, 438, 488, 550, 620–621, 660, 680–691, 695–709, 713–716, 775, 862–871, 901–948, 951
   ota_metadata.py3153190%147, 152, 188–189, 199–203, 215, 273, 306–308, 325–328, 408, 411, 419–421, 434, 443–448, 721–732
   ota_status.py15287%36, 44
   proxy_info.py51786%82–87, 122–129, 137–138
   update_stats.py105298%162, 172
otaclient/app/boot_control
   __init__.py40100% 
   _cboot.py28814251%82–90, 99–112, 118–121, 125, 132, 136, 140, 144–148, 152–156, 163–175, 178–221, 227, 230, 233, 236, 239, 242, 245, 248–249, 252–253, 256–260, 263–264, 279, 282, 316, 333–336, 349–352, 362–365, 373, 412, 429–432, 441–444, 449–451, 460–466, 469, 476, 506–509, 548–551, 556–567, 572–578
   _common.py36914361%65–74, 83–84, 88–89, 97–98, 109–110, 115–120, 125–130, 139, 148, 152, 156, 160, 174–177, 187–191, 196, 200, 210–214, 222–234, 245–249, 253–257, 269–271, 283–285, 296–310, 320–341, 360–376, 393–404, 412–418, 513–523, 582–583, 637, 641–642, 645, 653–656, 712–713, 716, 730–738, 753–754, 828–831, 852–855, 868–869, 878
   _errors.py471960%43–69, 89–90
   _grub.py40311472%217, 265–268, 274–278, 315–316, 323–347, 356–362, 371–377, 456–462, 514, 520, 546, 568–573, 588–590, 619–629, 684–690, 709–712, 737–740, 763–766, 808, 814, 834–837, 849, 852, 855, 858, 862–864, 882–885, 913–916, 921–929, 934–942
   _rpi_boot.py26612553%85–87, 93–148, 172–174, 180–182, 195–197, 203–205, 218–243, 248, 252, 256, 260, 294, 324, 327–329, 337, 346–349, 359–362, 366–373, 413–415, 457–461, 480–483, 488, 491, 512–515, 520–528, 533–541, 555–558, 564–566, 569
   configs.py58297%46–47
   firmware.py32584%63, 65, 76–78
   protocol.py28582%53, 57, 61, 65, 73
   selecter.py392731%45–69, 77–94
otaclient/app/create_standby
   __init__.py12558%30–36
   common.py2164579%74, 77–78, 82–95, 141, 189–197, 200–203, 207, 218, 292–300, 312, 356–361, 377–378, 392–396, 421–422
   interface.py19384%55, 59, 63
   rebuild_mode.py89199%106
otaclient/app/proto
   __init__.py31390%37, 44–45
   _common.py4194988%85, 163, 170, 182–184, 203, 208, 219, 256, 262, 267, 298, 302, 306, 363, 380, 403, 464, 471, 474, 494, 501, 503, 529, 535, 538, 540, 565, 571, 574, 576, 605, 609, 611, 625, 642, 670, 673, 677, 680, 708, 714, 761–766, 797
   _ota_metafiles_wrapper.py841385%37, 40–42, 112–116, 122–125
   _otaclient_v2_pb2_wrapper.py2763787%87, 90–93, 132, 175, 183, 197, 207, 210–213, 258, 261, 264–265, 285, 305, 385, 452, 505, 513–515, 519–522, 525–530, 551, 559, 573, 581, 595
   streamer.py43881%32, 47, 65–66, 71, 80–81, 99
   wrapper.py40100% 
otaclient/ota_proxy
   __init__.py46393%86, 90, 94
   __main__.py22220%16–79
   _consts.py150100% 
   cache_control.py68494%71, 91, 113, 121
   config.py180100% 
   db.py1461590%75, 81, 103, 113–116, 145–147, 166, 199, 208–209, 229, 258, 300
   errors.py100100% 
   orm.py1151190%37, 91, 96, 101, 107, 113, 140–141, 154, 231, 235
   ota_cache.py4047581%95–96, 215, 226, 253–255, 275, 291–294, 317–330, 359–363, 379, 440–441, 483–484, 554, 567–570, 620, 639–640, 672–673, 684, 721–728, 735–736, 741–743, 747, 756, 803, 811–813, 892–895, 899–903, 917–934, 965, 971, 998, 1027–1029
   server_app.py1383972%75, 78, 84, 100, 102, 161–170, 212–243, 256–266, 292–298, 312–314, 320–322
   utils.py23196%31
TOTAL6022130778% 

Base automatically changed from fix/persist_file_handling to v3.6.x March 4, 2024 03:06
@Bodong-Yang Bodong-Yang self-assigned this Mar 4, 2024
@Bodong-Yang Bodong-Yang added the bug Something isn't working label Mar 4, 2024
@Bodong-Yang Bodong-Yang marked this pull request as ready for review March 4, 2024 03:24
@Bodong-Yang Bodong-Yang merged commit dfd1237 into v3.6.x Mar 4, 2024
3 checks passed
@Bodong-Yang Bodong-Yang deleted the fix/swapfile branch March 4, 2024 08:11
@Bodong-Yang Bodong-Yang changed the title fix: properly handling swapfile during persist file handling fix(v3.6.x): properly handling swapfile during persist file handling Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant