-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat!: reject any OTA update/rollback request on ecu_info.yaml not properly loaded #465
Changes from 13 commits
7aeb00f
d1d8c8b
be4b701
2bf897b
36764ae
62b5572
679e91d
a274805
19f9efa
2c190cc
681b791
10a1bf1
b4de8d7
a06972a
5f00866
5c3861a
7a542de
668fa8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
import requests.exceptions as requests_exc | ||
from requests import Response | ||
|
||
import otaclient.configs.cfg as otaclient_cfg | ||
from ota_metadata.legacy import parser as ota_metadata_parser | ||
from ota_metadata.legacy import types as ota_metadata_types | ||
from ota_metadata.utils.cert_store import ( | ||
|
@@ -672,17 +673,7 @@ def __init__( | |
) | ||
return | ||
|
||
# load and report booted OTA status | ||
_boot_ctrl_loaded_ota_status = self.boot_controller.get_booted_ota_status() | ||
self._live_ota_status = _boot_ctrl_loaded_ota_status | ||
status_report_queue.put_nowait( | ||
StatusReport( | ||
payload=OTAStatusChangeReport( | ||
new_ota_status=_boot_ctrl_loaded_ota_status, | ||
), | ||
) | ||
) | ||
|
||
# ------ load firmware version ------ # | ||
self.current_version = self.boot_controller.load_version() | ||
status_report_queue.put_nowait( | ||
StatusReport( | ||
|
@@ -691,7 +682,9 @@ def __init__( | |
), | ||
) | ||
) | ||
logger.info(f"firmware_version: {self.current_version}") | ||
|
||
# ------ load CA store ------ # | ||
self.ca_chains_store = None | ||
try: | ||
self.ca_chains_store = load_ca_cert_chains(cfg.CERT_DPATH) | ||
|
@@ -701,9 +694,36 @@ def __init__( | |
|
||
self.ca_chains_store = CAChainStore() | ||
|
||
self.started = True | ||
logger.info("otaclient started") | ||
logger.info(f"firmware_version: {self.current_version}") | ||
# load and report booted OTA status | ||
_boot_ctrl_loaded_ota_status = self.boot_controller.get_booted_ota_status() | ||
if not otaclient_cfg.ECU_INFO_LOADED_SUCCESSFULLY: | ||
logger.error( | ||
"ecu_info.yaml file is not loaded properly, will reject any OTA request." | ||
) | ||
logger.error(f"set live_ota_status to {OTAStatus.FAILURE!r}") | ||
self._live_ota_status = OTAStatus.FAILURE | ||
status_report_queue.put_nowait( | ||
StatusReport( | ||
payload=OTAStatusChangeReport( | ||
new_ota_status=OTAStatus.FAILURE, | ||
failure_type=FailureType.UNRECOVERABLE, | ||
failure_reason=f"ecu_info.yaml file is broken or missing, please check {cfg.ECU_INFO_FPATH}. " | ||
"reject any OTA request.", | ||
), | ||
) | ||
) | ||
else: | ||
self._live_ota_status = _boot_ctrl_loaded_ota_status | ||
status_report_queue.put_nowait( | ||
StatusReport( | ||
payload=OTAStatusChangeReport( | ||
new_ota_status=_boot_ctrl_loaded_ota_status, | ||
), | ||
) | ||
) | ||
|
||
self.started = True | ||
logger.info("otaclient started") | ||
Comment on lines
+702
to
+731
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ecu_info.yaml is not loaded properly, we will just set the otaclient as NOT started, any requests coming to otaclient will be rejected when otaclient is not started. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that when ecu_info.yaml is broken, only the live_ota_status(in the memory) will be set to FAILURE, the |
||
|
||
def _on_failure( | ||
self, | ||
|
@@ -843,6 +863,19 @@ def main( | |
) | ||
) | ||
|
||
elif not self.started: | ||
_err_msg = ( | ||
"otaclient is not started, might be due to broken ecu_info.yaml" | ||
) | ||
logger.error(_err_msg) | ||
resp_queue.put_nowait( | ||
IPCResponse( | ||
res=IPCResEnum.REJECT_OTHER, | ||
msg=_err_msg, | ||
session_id=request.session_id, | ||
) | ||
) | ||
|
||
elif isinstance(request, UpdateRequestV2): | ||
|
||
_update_thread = threading.Thread( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, if the OTAStatusChangeReport reported too quickly, the newly coming report will be dropped, resulting in the OTA status not being updated. That is not proper, fixed in this PR.