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

refine(v3.7.x): refactor proxy_info.yaml and ecu_info.yaml config files parsing #286

Merged
merged 18 commits into from
Apr 17, 2024

Conversation

Bodong-Yang
Copy link
Member

@Bodong-Yang Bodong-Yang commented Apr 10, 2024

Description

This PR refactors the implementation of proxy_info.yaml and ecu_info.yaml config files parsing. Now these two configs files are parsed and validated by pyyaml and pydantic. The implementation now also aligns with the documentation, see ecu_info.yaml specification and proxy_info.yaml specification for more details.

Also, now the logic of parsing these two config files are separated from otaclient.app package and implemented at otaclient.config package. For the otaclient package level config package, see otaclient package scope configs infra for more details.

Check list

  • test file(s) that covers the change(s) is implemented.
  • local test is passed.
  • VM tests passed.

Changes

Behavior changes

Does this PR introduce behavior change(s)?

  • No.

Breaking change

Does this PR introduce breaking change?

  • No.

Related links & tickets

@Bodong-Yang Bodong-Yang added the refactor Rewrite/remove related code instead of patching them label Apr 10, 2024
Comment on lines +77 to +78
if bootloader_type is BootloaderType.AUTO_DETECT:
bootloader_type = detect_bootloader()
Copy link
Member Author

@Bodong-Yang Bodong-Yang Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: BootloaderType.UNSPECIFIC is renamed to AUTO_DETECT for better understanding. But AUTO_DETECT is deprecated and should not be used in the future.

Copy link
Contributor

github-actions bot commented Apr 10, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
otaclient/app
   __init__.py00100% 
   __main__.py330%16–19
   common.py3753291%63, 193, 208, 283–285, 295, 304–306, 412, 424, 543–547, 635, 637, 669–671, 673, 699–702, 707, 711–715, 741–742
   configs.py760100% 
   downloader.py2714484%68, 81–82, 297, 302, 306, 324–325, 375–379, 398–408, 429–447, 456, 531–533, 549, 569–587
   errors.py1130100% 
   interface.py17476%32, 43, 47, 51
   log_setting.py55787%39–40, 52, 54, 65–67
   main.py29293%43–44
   ota_client.py39814963%55–56, 76, 182–206, 243–246, 258–274, 284–287, 292–330, 372–375, 380–387, 400–423, 429–432, 461–485, 499–506, 513, 516–522, 569–572, 580, 616, 621–643, 703–719, 730–746, 757, 776, 787–788, 805, 824, 828–829, 844
   ota_client_call.py38684%42–44, 80–82
   ota_client_service.py27389%55–57
   ota_client_stub.py39310873%76–81, 89–97, 101–123, 128–137, 140–147, 155–160, 197–199, 204, 240, 265, 268, 271, 375, 401, 403, 429, 479, 541, 611–612, 651, 670–681, 685–699, 703–706, 759, 846–855, 885–932, 935
   ota_metadata.py3153190%145, 150, 186–187, 197–201, 213, 271, 304–306, 323–326, 406, 409, 417–419, 432, 441–446, 719–730
   ota_status.py14286%34, 42
   update_stats.py105298%160, 170
otaclient/app/boot_control
   __init__.py40100% 
   _cboot.py28914251%81–89, 98–111, 117–120, 124, 131, 135, 139, 143–147, 151–155, 162–174, 177–220, 226, 229, 232, 235, 238, 241, 244, 247–248, 251–252, 255–259, 262–263, 278, 281, 315, 332–335, 348–351, 361–364, 372, 411, 428–431, 440–443, 448–450, 459–465, 468, 475, 505–508, 547–550, 555–566, 571–577
   _common.py36914361%63–72, 81–82, 86–87, 95–96, 107–108, 113–118, 123–128, 137, 146, 150, 154, 158, 172–175, 185–189, 194, 198, 208–212, 220–232, 243–247, 251–255, 267–269, 281–283, 294–308, 318–339, 358–374, 391–402, 410–416, 511–521, 580–581, 635, 639–640, 643, 651–654, 710–711, 714, 728–736, 751–752, 826–829, 850–853, 866–867, 876
   _errors.py471960%43–69, 89–90
   _grub.py40411472%216, 264–267, 273–277, 314–315, 322–346, 355–361, 370–376, 455–461, 513, 519, 545, 567–572, 587–589, 618–628, 683–689, 708–711, 736–739, 762–765, 807, 813, 833–836, 848, 851, 854, 857, 861–863, 881–884, 912–915, 920–928, 933–941
   _rpi_boot.py26712553%84–86, 92–147, 171–173, 179–181, 194–196, 202–204, 217–242, 247, 251, 255, 259, 293, 323, 326–328, 336, 345–348, 358–361, 365–372, 412–414, 456–460, 479–482, 487, 490, 511–514, 519–527, 532–540, 554–557, 563–565, 568
   configs.py420100% 
   firmware.py31584%60, 62, 73–75
   protocol.py28582%53, 57, 61, 65, 73
   selecter.py392633%44–69, 77–94
otaclient/app/create_standby
   __init__.py12558%28–34
   common.py2164579%72, 75–76, 80–93, 139, 187–195, 198–201, 205, 216, 290–298, 310, 354–359, 375–376, 390–394, 419–420
   interface.py19384%55, 59, 63
   rebuild_mode.py89199%104
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
TOTAL5947130678% 

Comment on lines 102 to 90
# NOTE(20240306): for only god knows reason, although in proxy_info.yaml,
# the logging_server field is assigned with an URL, and otaclient
# expects an URL, the run.sh from autoware_ecu_system_setup pass in
# HTTP_LOGGING_SERVER with URL schema being removed!?
# NOTE: I will do a quick fix here as I don't want to touch autoware_ecu_system_setup
# for now, leave it in the future.
if iot_logger_url := os.environ.get("HTTP_LOGGING_SERVER"):
# special treatment for not-a-URL passed in by run.sh
# note that we only support http, the proxy_info.yaml should be properly setup.
if not (iot_logger_url.startswith("http") or iot_logger_url.startswith("HTTP")):
iot_logger_url = f"http://{iot_logger_url.strip('/')}"
if iot_logger_url := str(proxy_info.logging_server):
iot_logger_url = f"{iot_logger_url.strip('/')}/"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: after we directly parse the logging_server setting from proxy_info.yaml, we don't need to read the environmental vars and the special treatment code can be removed.

@Bodong-Yang Bodong-Yang marked this pull request as ready for review April 10, 2024 03:14
@Bodong-Yang Bodong-Yang merged commit 5ce87a1 into v3.7.x Apr 17, 2024
3 checks passed
@Bodong-Yang Bodong-Yang deleted the backport/v3.7.x/ecu_info_proxy_info branch April 17, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Rewrite/remove related code instead of patching them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant