From 1eceef4b273338f7b1d4bfa8cfc273289a94f90b Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 27 Oct 2023 01:40:26 +0000 Subject: [PATCH 1/9] grub: adding deprecation warning related to slot management --- otaclient/app/boot_control/_grub.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index a65281298..05977e3f0 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -11,6 +11,22 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Implementation of grub boot control. + +DEPRECATION WARNING(2023.10.26): + Current mechanism of defining and detecting slots is proved to be not robust. + The design expects that rootfs device will always be sda, which might not be guaranteed + as the sdx naming scheme is based on the order of kernel recognizing block devices. + If rootfs somehow is not named as sda, the grub boot controller will fail to identifiy the + slots and failing the OTA. + +TODO(2023.10.26): New mechanism to define and manage slot is needed. + +NOTE(2023.10.27) A fix is applied to workaround the edge case of rootfs not named as sda, + by regardless of which device name is assigned to rootfs dev, always manage ota-partition file + with sda. This workaround only means to avoid OTA failed on edge condition, still + expecting new mechanism to be introduced. +""" import re From 2eff924e407bf997ad0d0a49914610cf03bca104 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 27 Oct 2023 02:16:58 +0000 Subject: [PATCH 2/9] grub: always naming slot_id with schema sda --- otaclient/app/boot_control/_grub.py | 47 ++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 05977e3f0..92046fd60 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -17,8 +17,10 @@ Current mechanism of defining and detecting slots is proved to be not robust. The design expects that rootfs device will always be sda, which might not be guaranteed as the sdx naming scheme is based on the order of kernel recognizing block devices. - If rootfs somehow is not named as sda, the grub boot controller will fail to identifiy the - slots and failing the OTA. + If rootfs somehow is not named as sda, the grub boot controller will fail to identifiy + the slots and/or finding corresponding ota-partition files, finally failing the OTA. + Also slots are detected by assuming the partition layout, which is less robust comparing to + cboot and rpi_boot implementation of boot controller. TODO(2023.10.26): New mechanism to define and manage slot is needed. @@ -298,11 +300,24 @@ class GrubABPartitionDetector: - sdx3: A partition - sdx4: B partition - slot_name is the dev name of the A/B partition. + slot_name is sda. For example, if current slot's device is + nvme0n1p3, then the slot_name is sda3. + We assume that last 2 partitions are A/B partitions, error will be raised if the current rootfs is not one of the last 2 partitions. + + WARNING(2023.10.27): as workaround to resolving the wrong assumption that rootfs + device is always sda, we decouple the slot naming and device name here, + always searching and naming slot with "sda" as prefix. + NOTE(2023.10.26): expecting new mechanism to define slot with higher robustness. """ + # assuming that the suffix digit are the partiton id, for example, + # sda3's pid is 3, nvme0n1p3's pid is also 3. + DEV_PATH_PA: ClassVar[re.Pattern] = re.compile( + r"^/dev/(?P\w*[a-z])(?P\d+)$" + ) + def __init__(self) -> None: self.active_slot, self.active_dev = self._detect_active_slot() self.standby_slot, self.standby_dev = self._detect_standby_slot(self.active_dev) @@ -337,23 +352,41 @@ def _get_sibling_dev(self, active_dev: str) -> str: ) def _detect_active_slot(self) -> Tuple[str, str]: - """ + """Get active slot's slot_id. + + NOTE(2023.10.27): always naming the slot with schema sda, + regardless of whether rootfs device is sda or not. + Returns: A tuple contains the slot_name and the full dev path of the active slot. """ dev_path = CMDHelperFuncs.get_current_rootfs_dev() - slot_name = dev_path.lstrip("/dev/") + _dev_path_ma = self.DEV_PATH_PA.match(dev_path) + assert _dev_path_ma and ( + _pid := _dev_path_ma.group("partition_id") + ), f"failed to parse active device path: {dev_path=}" + + slot_name = f"sda{_pid}" return slot_name, dev_path def _detect_standby_slot(self, active_dev: str) -> Tuple[str, str]: - """ + """Get standby slot's slot_id. + + NOTE(2023.10.27): always naming the slot with schema sda, + regardless of whether rootfs device is sda or not. + Returns: A tuple contains the slot_name and the full dev path of the standby slot. """ dev_path = self._get_sibling_dev(active_dev) - slot_name = dev_path.lstrip("/dev/") + _dev_path_ma = self.DEV_PATH_PA.match(dev_path) + assert _dev_path_ma and ( + _pid := _dev_path_ma.group("partition_id") + ), f"failed to parse standby device path: {dev_path=}" + + slot_name = f"sda{_pid}" return slot_name, dev_path From 5831c44147828c702213947c301812ec62dc607f Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 27 Oct 2023 03:21:07 +0000 Subject: [PATCH 3/9] grub: L402 add logging for active/standby slot's devices path --- otaclient/app/boot_control/_grub.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 92046fd60..0cfb7983d 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -399,7 +399,9 @@ def __init__(self) -> None: self.standby_root_dev = ab_detector.standby_dev self.active_slot = ab_detector.active_slot self.standby_slot = ab_detector.standby_slot - logger.info(f"{self.active_slot=}, {self.standby_slot=}") + logger.info( + f"{self.active_slot=}@{self.active_root_dev}, {self.standby_slot=}@{self.standby_root_dev}" + ) self.boot_dir = Path(cfg.BOOT_DIR) self.grub_file = Path(cfg.GRUB_CFG_PATH) From 6cad815603843ee8187aa475836e1fdcb1984728 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 27 Oct 2023 06:11:09 +0000 Subject: [PATCH 4/9] minor update --- otaclient/app/boot_control/_grub.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 0cfb7983d..3cca927dd 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -13,7 +13,7 @@ # limitations under the License. """Implementation of grub boot control. -DEPRECATION WARNING(2023.10.26): +DEPRECATION WARNING(2023.10.26): Current mechanism of defining and detecting slots is proved to be not robust. The design expects that rootfs device will always be sda, which might not be guaranteed as the sdx naming scheme is based on the order of kernel recognizing block devices. @@ -317,6 +317,7 @@ class GrubABPartitionDetector: DEV_PATH_PA: ClassVar[re.Pattern] = re.compile( r"^/dev/(?P\w*[a-z])(?P\d+)$" ) + SLOT_NAME_PREFIX: ClassVar[str] = "sda" def __init__(self) -> None: self.active_slot, self.active_dev = self._detect_active_slot() @@ -367,7 +368,7 @@ def _detect_active_slot(self) -> Tuple[str, str]: _pid := _dev_path_ma.group("partition_id") ), f"failed to parse active device path: {dev_path=}" - slot_name = f"sda{_pid}" + slot_name = f"{self.SLOT_NAME_PREFIX}{_pid}" return slot_name, dev_path def _detect_standby_slot(self, active_dev: str) -> Tuple[str, str]: @@ -386,7 +387,7 @@ def _detect_standby_slot(self, active_dev: str) -> Tuple[str, str]: _pid := _dev_path_ma.group("partition_id") ), f"failed to parse standby device path: {dev_path=}" - slot_name = f"sda{_pid}" + slot_name = f"{self.SLOT_NAME_PREFIX}{_pid}" return slot_name, dev_path From a0ac57b34bbbd6a1d1a8d75437b277800048e56e Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 27 Oct 2023 06:56:48 +0000 Subject: [PATCH 5/9] update tests/keys --- tests/keys/interm.pem | 18 +++++++++--------- tests/keys/root.pem | 18 +++++++++--------- tests/keys/sign.key | 6 +++--- tests/keys/sign.pem | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/keys/interm.pem b/tests/keys/interm.pem index 054da0795..1dfc0df46 100644 --- a/tests/keys/interm.pem +++ b/tests/keys/interm.pem @@ -1,13 +1,13 @@ -----BEGIN CERTIFICATE----- -MIIB6zCCAZCgAwIBAgIUWO/ANSZ6jsn+aIK9RQDgniCR92gwCgYIKoZIzj0EAwIw +MIIB6jCCAZCgAwIBAgIUclYCFrRLcGCulcyR1uc8oA7t8vYwCgYIKoZIzj0EAwIw RTELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRva3lvMQ4wDAYDVQQKDAVUaWVyNDEW -MBQGA1UEAwwNcm9vdC50aWVyNC5qcDAeFw0yMjEwMDMwNDE5MDNaFw0zMjEwMDUw -NDE5MDNaME0xCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UECgwF +MBQGA1UEAwwNcm9vdC50aWVyNC5qcDAeFw0yMzEwMjcwNjU2MjdaFw0zMzEwMjkw +NjU2MjdaME0xCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UECgwF VGllcjQxHjAcBgNVBAMMFWludGVybWVkaWF0ZS50aWVyNC5qcDBZMBMGByqGSM49 -AgEGCCqGSM49AwEHA0IABBKX8h546xKxJR8qArXmyBngW/T9+XbxowBssCg0yjZ6 -/tsRNPF5RlCDzI4C8DactlQP0t27NvxZQQhXFXpr4kujVjBUMB0GA1UdDgQWBBSL -03kBOi7DPLY0IQ+Q5ci4ObMfJzAfBgNVHSMEGDAWgBTUIPiXLIF4b/36Hgu4S/KU -sBjhGDASBgNVHRMBAf8ECDAGAQH/AgEAMAoGCCqGSM49BAMCA0kAMEYCIQCWNbaK -dkGer4rjV1rdkHv+jN5iYqL0H4ZeFKZ7wbgdKQIhAMZb8AC+Va1o1L0U9294jdI0 -aooIZ7UavjKy6t0mXB99 +AgEGCCqGSM49AwEHA0IABIu6gNzIRcDFoykqMWBRCxQfBx2BGK5lfFbJAfgYvxNN +OViBFZDOPxTHhFmuFX6txaT4pqfpWhQXpP2h+VzpCuGjVjBUMB0GA1UdDgQWBBRi +ik8kqC+T+dNnU1eML+lLEKAOGzAfBgNVHSMEGDAWgBRSteexpfLelFY6oPQL1dXH +Ky5+kTASBgNVHRMBAf8ECDAGAQH/AgEAMAoGCCqGSM49BAMCA0gAMEUCIHb9ZcDN +z3RUhVXaJd8WvkUlYHPNP5LP+0IFaJ7IzumTAiEAo1nLsbCF8WkLf4VXtJNk9Hu3 +1MbvWqS/Hhk5+tV7+AI= -----END CERTIFICATE----- diff --git a/tests/keys/root.pem b/tests/keys/root.pem index 1d1b72300..a5f3702e6 100644 --- a/tests/keys/root.pem +++ b/tests/keys/root.pem @@ -1,13 +1,13 @@ -----BEGIN CERTIFICATE----- -MIIB3zCCAYWgAwIBAgIUVcCyMLO2J6JKxw8Ye4cn21ty8XUwCgYIKoZIzj0EAwIw +MIIB3jCCAYWgAwIBAgIUGYEMZsuwqHrRhrLot++BqE+xbQ4wCgYIKoZIzj0EAwIw RTELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRva3lvMQ4wDAYDVQQKDAVUaWVyNDEW -MBQGA1UEAwwNcm9vdC50aWVyNC5qcDAeFw0yMjEwMDMwNDE5MDNaFw0zMjEwMDUw -NDE5MDNaMEUxCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UECgwF +MBQGA1UEAwwNcm9vdC50aWVyNC5qcDAeFw0yMzEwMjcwNjU2MjdaFw0zMzEwMjkw +NjU2MjdaMEUxCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UECgwF VGllcjQxFjAUBgNVBAMMDXJvb3QudGllcjQuanAwWTATBgcqhkjOPQIBBggqhkjO -PQMBBwNCAARH1pYCjqPrXGGVIsMWIXvRIZfNCSH07X1iPn3lyNq7kIN4bJFiHdMi -LxxOh94uvhh7psYcrDizFi/l3SsLihbxo1MwUTAdBgNVHQ4EFgQU1CD4lyyBeG/9 -+h4LuEvylLAY4RgwHwYDVR0jBBgwFoAU1CD4lyyBeG/9+h4LuEvylLAY4RgwDwYD -VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiEAhJLAk9SRQ2Q61m9e2VoM -m86odWMLRv+EKbpWebe4WTwCICnch1agvDomA7PMbkPvg0kz/jot2YoN3xZ24O6G -zjmb +PQMBBwNCAAR6Fa70+SJgvwq0adME6CAqq4VwNeJhAUxUdgz9QS+DpI7LcdMS6cmq +3EqA2vJ5Z9jpVAOUuJ2kXqrtalhN69bCo1MwUTAdBgNVHQ4EFgQUUrXnsaXy3pRW +OqD0C9XVxysufpEwHwYDVR0jBBgwFoAUUrXnsaXy3pRWOqD0C9XVxysufpEwDwYD +VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiACPOdQ/zjz+tokGgb6APQp +ptM9N5JXgHTYTFBBpT72cAIgIWCnbPU68z6YiI4A1JqMzO4mUfnSP+5ssWTHLC2O +Bfg= -----END CERTIFICATE----- diff --git a/tests/keys/sign.key b/tests/keys/sign.key index 7ee6428d8..7eedbdf90 100644 --- a/tests/keys/sign.key +++ b/tests/keys/sign.key @@ -2,7 +2,7 @@ BggqhkjOPQMBBw== -----END EC PARAMETERS----- -----BEGIN EC PRIVATE KEY----- -MHcCAQEEIFBCLuRbpajW14w5MMqAjprChcTHz6+s0NxLEZaL6uTXoAoGCCqGSM49 -AwEHoUQDQgAEGxHFx+A641vv8cZ4M/YnrstGo0JfyTdGyaXX7Q5T9z0yRF0B35US -sqYSlja5cgt2bmJxk8EJrHxfUBrSQLi3PQ== +MHcCAQEEIDdgqKIQ3e30Dp0ZHz1ZWxkR6OAACEVCru/Klrepmj9xoAoGCCqGSM49 +AwEHoUQDQgAET8KH6J7rVkECpv9WfGGyyv4hj1ck8vBPMpLZSneePFzMFlxi0pYA +u2qsM/vssHsWi3j3Gii0l/CtyQSK1OK75g== -----END EC PRIVATE KEY----- diff --git a/tests/keys/sign.pem b/tests/keys/sign.pem index 988725130..ca325fcab 100644 --- a/tests/keys/sign.pem +++ b/tests/keys/sign.pem @@ -1,11 +1,11 @@ -----BEGIN CERTIFICATE----- -MIIBjjCCATMCFAgcTp8kYozCqL4Aib6cooc5o2tnMAoGCCqGSM49BAMCME0xCzAJ +MIIBjTCCATMCFG4r2lF/oNv7Ew2T7XDbfuQEuOW3MAoGCCqGSM49BAMCME0xCzAJ BgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UECgwFVGllcjQxHjAcBgNV -BAMMFWludGVybWVkaWF0ZS50aWVyNC5qcDAeFw0yMjEwMDMwNDE5MDNaFw0yMzEw -MDMwNDE5MDNaMEUxCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UE +BAMMFWludGVybWVkaWF0ZS50aWVyNC5qcDAeFw0yMzEwMjcwNjU2MjdaFw0yNDEw +MjYwNjU2MjdaMEUxCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVUb2t5bzEOMAwGA1UE CgwFVGllcjQxFjAUBgNVBAMMDXNpZ24udGllcjQuanAwWTATBgcqhkjOPQIBBggq -hkjOPQMBBwNCAAQbEcXH4DrjW+/xxngz9ieuy0ajQl/JN0bJpdftDlP3PTJEXQHf -lRKyphKWNrlyC3ZuYnGTwQmsfF9QGtJAuLc9MAoGCCqGSM49BAMCA0kAMEYCIQCx -Pn2DN1k1M2X1+96qTkvwCibD3uDB1pPMdM0oBRWFswIhAIwU9tRlTQj1M3TShBuP -01qYR4cuhMyec7VLI0VPyfBa +hkjOPQMBBwNCAARPwofonutWQQKm/1Z8YbLK/iGPVyTy8E8yktlKd548XMwWXGLS +lgC7aqwz++ywexaLePcaKLSX8K3JBIrU4rvmMAoGCCqGSM49BAMCA0gAMEUCIQCL +U0RAelUktN4KWBk/S3ZL7pV6BHIz5pir8QN7pzGuwQIgdrkTFIGSeNoLIi1naZbU +16HdWbQJOVtrmjHx1tZBP7o= -----END CERTIFICATE----- From 41baf979d020ae59928fb972e4515d68d844e98d Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Mon, 30 Oct 2023 00:40:57 +0000 Subject: [PATCH 6/9] grub: minor cleanup to comments --- otaclient/app/boot_control/_grub.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 3cca927dd..235985821 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -13,7 +13,7 @@ # limitations under the License. """Implementation of grub boot control. -DEPRECATION WARNING(2023.10.26): +DEPRECATION WARNING(20231026): Current mechanism of defining and detecting slots is proved to be not robust. The design expects that rootfs device will always be sda, which might not be guaranteed as the sdx naming scheme is based on the order of kernel recognizing block devices. @@ -22,12 +22,12 @@ Also slots are detected by assuming the partition layout, which is less robust comparing to cboot and rpi_boot implementation of boot controller. -TODO(2023.10.26): New mechanism to define and manage slot is needed. +TODO(20231026): design new mechanism to define and manage slot. -NOTE(2023.10.27) A fix is applied to workaround the edge case of rootfs not named as sda, - by regardless of which device name is assigned to rootfs dev, always manage ota-partition file - with sda. This workaround only means to avoid OTA failed on edge condition, still - expecting new mechanism to be introduced. +NOTE(20231027) A workaround fix is applied to handle the edge case of rootfs not named as sda, + Check GrubABPartitionDetector class for more details. + This workaround only means to avoid OTA failed on edge condition and maintain backward compatibility, + still expecting new mechanism to fundamentally resolve this issue. """ @@ -300,16 +300,12 @@ class GrubABPartitionDetector: - sdx3: A partition - sdx4: B partition - slot_name is sda. For example, if current slot's device is - nvme0n1p3, then the slot_name is sda3. - We assume that last 2 partitions are A/B partitions, error will be raised if the current rootfs is not one of the last 2 partitions. - WARNING(2023.10.27): as workaround to resolving the wrong assumption that rootfs - device is always sda, we decouple the slot naming and device name here, - always searching and naming slot with "sda" as prefix. - NOTE(2023.10.26): expecting new mechanism to define slot with higher robustness. + NOTE(20231027): as workaround to rootfs not sda breaking OTA, slot naming schema + is fixed to "sda", and ota-partition folder is searched with this name. + For example, if current slot's device is nvme0n1p3, the slot_name is sda3. """ # assuming that the suffix digit are the partiton id, for example, @@ -355,9 +351,6 @@ def _get_sibling_dev(self, active_dev: str) -> str: def _detect_active_slot(self) -> Tuple[str, str]: """Get active slot's slot_id. - NOTE(2023.10.27): always naming the slot with schema sda, - regardless of whether rootfs device is sda or not. - Returns: A tuple contains the slot_name and the full dev path of the active slot. @@ -374,9 +367,6 @@ def _detect_active_slot(self) -> Tuple[str, str]: def _detect_standby_slot(self, active_dev: str) -> Tuple[str, str]: """Get standby slot's slot_id. - NOTE(2023.10.27): always naming the slot with schema sda, - regardless of whether rootfs device is sda or not. - Returns: A tuple contains the slot_name and the full dev path of the standby slot. From c8e51d72a8417a56c83aa037a1894e4f1c5de153 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Mon, 30 Oct 2023 00:42:17 +0000 Subject: [PATCH 7/9] minor comment update --- otaclient/app/boot_control/_grub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 235985821..a0352aacf 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -26,7 +26,7 @@ NOTE(20231027) A workaround fix is applied to handle the edge case of rootfs not named as sda, Check GrubABPartitionDetector class for more details. - This workaround only means to avoid OTA failed on edge condition and maintain backward compatibility, + This workaround only means to avoid OTA failed on edge condition and maintain backward compatibility, still expecting new mechanism to fundamentally resolve this issue. """ From 74d4dd383ab901f8330a1184fbbdce13277f2998 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Mon, 6 Nov 2023 01:41:52 +0000 Subject: [PATCH 8/9] grub@L360: minor fix --- otaclient/app/boot_control/_grub.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index a0352aacf..f24cbc505 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -357,10 +357,9 @@ def _detect_active_slot(self) -> Tuple[str, str]: """ dev_path = CMDHelperFuncs.get_current_rootfs_dev() _dev_path_ma = self.DEV_PATH_PA.match(dev_path) - assert _dev_path_ma and ( - _pid := _dev_path_ma.group("partition_id") - ), f"failed to parse active device path: {dev_path=}" + assert _dev_path_ma, f"dev path is invalid for OTA: {dev_path}" + _pid = _dev_path_ma.group("partition_id") slot_name = f"{self.SLOT_NAME_PREFIX}{_pid}" return slot_name, dev_path From a92b60ad3e20e07a6e1220931aab3fc9f97c2407 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Mon, 6 Nov 2023 01:44:11 +0000 Subject: [PATCH 9/9] grub@L375: minor fix --- otaclient/app/boot_control/_grub.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index f24cbc505..421901897 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -372,10 +372,9 @@ def _detect_standby_slot(self, active_dev: str) -> Tuple[str, str]: """ dev_path = self._get_sibling_dev(active_dev) _dev_path_ma = self.DEV_PATH_PA.match(dev_path) - assert _dev_path_ma and ( - _pid := _dev_path_ma.group("partition_id") - ), f"failed to parse standby device path: {dev_path=}" + assert _dev_path_ma, f"dev path is invalid for OTA: {dev_path}" + _pid = _dev_path_ma.group("partition_id") slot_name = f"{self.SLOT_NAME_PREFIX}{_pid}" return slot_name, dev_path