From 43e5566205cfb4dfa4a3da786656ba347ecc06bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Mon, 25 May 2026 13:21:26 +0200 Subject: [PATCH 1/8] Add data_source_names filter to verify_boot_sources_reimported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow callers to limit DataSource verification to a specific set, skipping custom DataSources without imagestreams. Ref: https://github.com/RedHatQE/openshift-virtualization-tests/pull/4968 Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 Signed-off-by: Ramón Lobillo --- utilities/hco.py | 1 + utilities/storage.py | 13 +++++++++++-- utilities/unittests/test_hco.py | 11 ++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/utilities/hco.py b/utilities/hco.py index 86f5a74392..fcabda3f3f 100644 --- a/utilities/hco.py +++ b/utilities/hco.py @@ -383,6 +383,7 @@ def enable_common_boot_image_import_spec_wait_for_data_import_cron(hco_resource, admin_client=admin_client, namespace=namespace.name, consecutive_checks_count=1, + data_source_names={next(iter(dict_entry)) for dict_entry in py_config["data_import_cron_matrix"]}, ) diff --git a/utilities/storage.py b/utilities/storage.py index dc16635262..1e80e64fbb 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -1119,9 +1119,12 @@ def get_data_sources_managed_by_data_import_cron(client: DynamicClient, namespac def verify_boot_sources_reimported( - admin_client: DynamicClient, namespace: str, consecutive_checks_count: int = 6 + admin_client: DynamicClient, + namespace: str, + consecutive_checks_count: int = 6, + data_source_names: list[str] | None = None, ) -> bool: - """Verify all DataImportCron-managed DataSources reach Ready=True. + """Verify DataImportCron-managed DataSources reach Ready=True. Checks DataSources sequentially each with its own timeout. Stops on the first DataSource that does not become ready. @@ -1130,12 +1133,18 @@ def verify_boot_sources_reimported( admin_client: Cluster admin client. namespace: Namespace containing the DataImportCron-managed DataSources. consecutive_checks_count: Consecutive Ready=True polls required for stability. + data_source_names: Verify DataSources whose name is in this + set. DataSources outside the set (e.g. from custom DIC templates) are + skipped. When None, all DIC-managed DataSources are verified. Returns: True if all DataSources reached Ready=True otherwise false """ try: for data_source in get_data_sources_managed_by_data_import_cron(client=admin_client, namespace=namespace): + if data_source_names is not None and data_source.name not in data_source_names: + LOGGER.info(f"Skipping DataSource {data_source.name}: not in golden image data source list") + continue LOGGER.info(f"Waiting for DataSource {data_source.name} consistent ready status") utilities.infra.wait_for_consistent_resource_conditions( dynamic_client=admin_client, diff --git a/utilities/unittests/test_hco.py b/utilities/unittests/test_hco.py index b764fdecba..d5d1ba71dd 100644 --- a/utilities/unittests/test_hco.py +++ b/utilities/unittests/test_hco.py @@ -766,7 +766,11 @@ def test_disable_when_enabled(self, mock_update_spec, mock_wait_deleted, mock_en except StopIteration: pass - mock_enable_spec.assert_called_once() + mock_enable_spec.assert_called_once_with( + hco_resource=mock_hco, + admin_client=mock_admin_client, + namespace=mock_namespace, + ) @patch("utilities.hco.enable_common_boot_image_import_spec_wait_for_data_import_cron") @patch("utilities.hco.wait_for_deleted_data_import_crons") @@ -797,6 +801,10 @@ def test_disable_when_already_disabled(self, mock_update_spec, mock_wait_deleted class TestEnableCommonBootImageImportSpecWaitForDataImportCron: """Test cases for enable_common_boot_image_import_spec_wait_for_data_import_cron""" + @patch( + "utilities.hco.py_config", + {"data_import_cron_matrix": [{"rhel9": {}}, {"fedora": {}}]}, + ) @patch("utilities.hco.wait_for_hco_conditions") @patch("utilities.hco.wait_for_ssp_conditions") @patch("utilities.hco.wait_for_at_least_one_auto_update_data_import_cron") @@ -828,6 +836,7 @@ def test_enable_spec( admin_client=mock_admin_client, namespace=mock_namespace.name, consecutive_checks_count=1, + data_source_names={"rhel9", "fedora"}, ) From d8cf506845514ab9dee841e5d490e8f32f3482b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Mon, 25 May 2026 14:18:46 +0200 Subject: [PATCH 2/8] Widen data_source_names type from list[str] to Collection[str] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The caller passes a set, so the type hint should accept any collection that supports membership checks. Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 Signed-off-by: Ramón Lobillo --- utilities/storage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utilities/storage.py b/utilities/storage.py index 1e80e64fbb..f789f851ab 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -2,6 +2,7 @@ import math import os import shlex +from collections.abc import Collection from collections.abc import Generator from contextlib import contextmanager from typing import Any @@ -1122,7 +1123,7 @@ def verify_boot_sources_reimported( admin_client: DynamicClient, namespace: str, consecutive_checks_count: int = 6, - data_source_names: list[str] | None = None, + data_source_names: Collection[str] | None = None, ) -> bool: """Verify DataImportCron-managed DataSources reach Ready=True. @@ -1134,7 +1135,7 @@ def verify_boot_sources_reimported( namespace: Namespace containing the DataImportCron-managed DataSources. consecutive_checks_count: Consecutive Ready=True polls required for stability. data_source_names: Verify DataSources whose name is in this - set. DataSources outside the set (e.g. from custom DIC templates) are + collection. DataSources outside the collection (e.g. from custom DIC templates) are skipped. When None, all DIC-managed DataSources are verified. Returns: From 5e243090ae137e865e3aa9505c4c23078975d027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Tue, 26 May 2026 14:21:27 +0200 Subject: [PATCH 3/8] Refactor data_source_names allowlist to exclude_data_source_names denylist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses review feedback: the allowlist approach using data_import_cron_matrix does not cover multiarch DataSource names (e.g. fedora-aarch64) and silently skips valid custom templates. The denylist keeps "verify all" as the default and lets callers exclude specific DataSources when needed. Propagates exclude_data_source_names through disable_common_boot_image_import_hco_spec so test_add_custom_data_import_cron_template_disable_spec can exclude the custom DataSource during teardown verification. Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 --- .../conftest.py | 18 ++++++++++++++++++ .../test_update_hco_cr.py | 2 +- utilities/hco.py | 8 ++++++-- utilities/storage.py | 12 ++++++------ utilities/unittests/test_hco.py | 7 ++----- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py index 99a74f2b13..5ef8bed9bd 100644 --- a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py +++ b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py @@ -3,6 +3,7 @@ from ocp_resources.pod import Pod from ocp_utilities.infra import get_pods_by_name_prefix +from tests.install_upgrade_operators.constants import CUSTOM_DATASOURCE_NAME from tests.install_upgrade_operators.hco_enablement_golden_image_updates.utils import ( CUSTOM_TEMPLATE, HCO_CR_DATA_IMPORT_SCHEDULE_KEY, @@ -15,6 +16,7 @@ HCO_OPERATOR, SSP_CR_COMMON_TEMPLATES_LIST_KEY_NAME, ) +from utilities.hco import disable_common_boot_image_import_hco_spec from utilities.ssp import get_ssp_resource @@ -113,3 +115,19 @@ def ssp_spec_templates_scope_function(ssp_resource_scope_function): @pytest.fixture(scope="session") def common_templates_scope_session(hyperconverged_status_scope_session): return hyperconverged_status_scope_session[SSP_CR_COMMON_TEMPLATES_LIST_KEY_NAME] + + +@pytest.fixture() +def disabled_boot_image_import_excluding_custom_datasource( + admin_client, + hyperconverged_resource_scope_function, + golden_images_namespace, + golden_images_data_import_crons_scope_function, +): + yield from disable_common_boot_image_import_hco_spec( + admin_client=admin_client, + hco_resource=hyperconverged_resource_scope_function, + golden_images_namespace=golden_images_namespace, + golden_images_data_import_crons=golden_images_data_import_crons_scope_function, + exclude_data_source_names={CUSTOM_DATASOURCE_NAME}, + ) diff --git a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py index cb49dbbbb3..f4ab855484 100644 --- a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py +++ b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py @@ -99,7 +99,7 @@ def test_add_custom_data_import_cron_template_disable_spec( self, admin_client, hco_namespace, - disabled_common_boot_image_import_hco_spec_scope_function, + disabled_boot_image_import_excluding_custom_datasource, hyperconverged_status_templates_scope_function, ssp_spec_templates_scope_function, image_stream_names, diff --git a/utilities/hco.py b/utilities/hco.py index fcabda3f3f..ee648c4461 100644 --- a/utilities/hco.py +++ b/utilities/hco.py @@ -352,6 +352,7 @@ def disable_common_boot_image_import_hco_spec( hco_resource, golden_images_namespace, golden_images_data_import_crons, + exclude_data_source_names=None, ): if hco_resource.instance.spec[ENABLE_COMMON_BOOT_IMAGE_IMPORT]: update_common_boot_image_import_spec( @@ -365,12 +366,15 @@ def disable_common_boot_image_import_hco_spec( hco_resource=hco_resource, admin_client=admin_client, namespace=golden_images_namespace, + exclude_data_source_names=exclude_data_source_names, ) else: yield -def enable_common_boot_image_import_spec_wait_for_data_import_cron(hco_resource, admin_client, namespace): +def enable_common_boot_image_import_spec_wait_for_data_import_cron( + hco_resource, admin_client, namespace, exclude_data_source_names=None +): hco_namespace = Namespace(name=hco_resource.namespace) update_common_boot_image_import_spec( hco_resource=hco_resource, @@ -383,7 +387,7 @@ def enable_common_boot_image_import_spec_wait_for_data_import_cron(hco_resource, admin_client=admin_client, namespace=namespace.name, consecutive_checks_count=1, - data_source_names={next(iter(dict_entry)) for dict_entry in py_config["data_import_cron_matrix"]}, + exclude_data_source_names=exclude_data_source_names, ) diff --git a/utilities/storage.py b/utilities/storage.py index f789f851ab..127af14acc 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -1123,7 +1123,7 @@ def verify_boot_sources_reimported( admin_client: DynamicClient, namespace: str, consecutive_checks_count: int = 6, - data_source_names: Collection[str] | None = None, + exclude_data_source_names: Collection[str] | None = None, ) -> bool: """Verify DataImportCron-managed DataSources reach Ready=True. @@ -1134,17 +1134,17 @@ def verify_boot_sources_reimported( admin_client: Cluster admin client. namespace: Namespace containing the DataImportCron-managed DataSources. consecutive_checks_count: Consecutive Ready=True polls required for stability. - data_source_names: Verify DataSources whose name is in this - collection. DataSources outside the collection (e.g. from custom DIC templates) are - skipped. When None, all DIC-managed DataSources are verified. + exclude_data_source_names: DataSources whose name is in this collection + are skipped (e.g. custom DIC templates without valid sources). + When None, all DIC-managed DataSources are verified. Returns: True if all DataSources reached Ready=True otherwise false """ try: for data_source in get_data_sources_managed_by_data_import_cron(client=admin_client, namespace=namespace): - if data_source_names is not None and data_source.name not in data_source_names: - LOGGER.info(f"Skipping DataSource {data_source.name}: not in golden image data source list") + if exclude_data_source_names is not None and data_source.name in exclude_data_source_names: + LOGGER.info(f"Skipping DataSource {data_source.name}: excluded from verification") continue LOGGER.info(f"Waiting for DataSource {data_source.name} consistent ready status") utilities.infra.wait_for_consistent_resource_conditions( diff --git a/utilities/unittests/test_hco.py b/utilities/unittests/test_hco.py index d5d1ba71dd..fab28c6c93 100644 --- a/utilities/unittests/test_hco.py +++ b/utilities/unittests/test_hco.py @@ -770,6 +770,7 @@ def test_disable_when_enabled(self, mock_update_spec, mock_wait_deleted, mock_en hco_resource=mock_hco, admin_client=mock_admin_client, namespace=mock_namespace, + exclude_data_source_names=None, ) @patch("utilities.hco.enable_common_boot_image_import_spec_wait_for_data_import_cron") @@ -801,10 +802,6 @@ def test_disable_when_already_disabled(self, mock_update_spec, mock_wait_deleted class TestEnableCommonBootImageImportSpecWaitForDataImportCron: """Test cases for enable_common_boot_image_import_spec_wait_for_data_import_cron""" - @patch( - "utilities.hco.py_config", - {"data_import_cron_matrix": [{"rhel9": {}}, {"fedora": {}}]}, - ) @patch("utilities.hco.wait_for_hco_conditions") @patch("utilities.hco.wait_for_ssp_conditions") @patch("utilities.hco.wait_for_at_least_one_auto_update_data_import_cron") @@ -836,7 +833,7 @@ def test_enable_spec( admin_client=mock_admin_client, namespace=mock_namespace.name, consecutive_checks_count=1, - data_source_names={"rhel9", "fedora"}, + exclude_data_source_names=None, ) From da4e9c4901b2d23ab05c47c175f3ade358f11b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Thu, 28 May 2026 09:06:43 +0200 Subject: [PATCH 4/8] De-quarantine test_add_custom_data_import_cron_template_disable_spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The teardown AssertionError in verify_boot_sources_reimported (CNV-88015) is fixed by the exclude_data_source_names denylist propagated through disable_common_boot_image_import_hco_spec. Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 --- .../test_update_hco_cr.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py index f4ab855484..9e9a9bc206 100644 --- a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py +++ b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py @@ -10,7 +10,6 @@ get_template_dict_by_name, get_templates_by_type_from_hco_status, ) -from utilities.constants import QUARANTINED from utilities.hco import ( update_hco_templates_spec, wait_for_auto_boot_config_stabilization, @@ -88,11 +87,6 @@ def test_add_custom_data_import_cron_template( ssp_spec_templates_scope_function=ssp_spec_templates_scope_function, ) - @pytest.mark.xfail( - reason=f"{QUARANTINED}: Teardown AssertionError in verify_boot_sources_reimported after re-enabling" - " enableCommonBootImageImport spec, CNV-88015", - run=False, - ) @pytest.mark.dependency(name="test_add_custom_data_import_cron_template_disable_spec") @pytest.mark.polarion("CNV-7914") def test_add_custom_data_import_cron_template_disable_spec( From 7cedf108d4da4c306823cffc9bee780fa0033210 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 13:16:44 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- utilities/storage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utilities/storage.py b/utilities/storage.py index 127af14acc..933f83a50c 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -2,8 +2,7 @@ import math import os import shlex -from collections.abc import Collection -from collections.abc import Generator +from collections.abc import Collection, Generator from contextlib import contextmanager from typing import Any From 08168799dfd6626cffdad038bfab381f99aae4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Tue, 2 Jun 2026 17:34:41 +0200 Subject: [PATCH 6/8] Address review feedback: usefixtures and non-default propagation tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move disabled_boot_image_import_excluding_custom_datasource to @pytest.mark.usefixtures since its return value is not used by the test. Add unit tests verifying exclude_data_source_names propagation with non-default values through both disable_common_boot_image_import_hco_spec and enable_common_boot_image_import_spec_wait_for_data_import_cron. Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 --- .../test_update_hco_cr.py | 2 +- utilities/unittests/test_hco.py | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py index 9e9a9bc206..3d6750f1fd 100644 --- a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py +++ b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/test_update_hco_cr.py @@ -89,11 +89,11 @@ def test_add_custom_data_import_cron_template( @pytest.mark.dependency(name="test_add_custom_data_import_cron_template_disable_spec") @pytest.mark.polarion("CNV-7914") + @pytest.mark.usefixtures("disabled_boot_image_import_excluding_custom_datasource") def test_add_custom_data_import_cron_template_disable_spec( self, admin_client, hco_namespace, - disabled_boot_image_import_excluding_custom_datasource, hyperconverged_status_templates_scope_function, ssp_spec_templates_scope_function, image_stream_names, diff --git a/utilities/unittests/test_hco.py b/utilities/unittests/test_hco.py index fab28c6c93..89a8a52d9f 100644 --- a/utilities/unittests/test_hco.py +++ b/utilities/unittests/test_hco.py @@ -773,6 +773,35 @@ def test_disable_when_enabled(self, mock_update_spec, mock_wait_deleted, mock_en exclude_data_source_names=None, ) + @patch("utilities.hco.enable_common_boot_image_import_spec_wait_for_data_import_cron") + @patch("utilities.hco.wait_for_deleted_data_import_crons") + @patch("utilities.hco.update_common_boot_image_import_spec") + def test_disable_propagates_exclude_data_source_names(self, mock_update_spec, mock_wait_deleted, mock_enable_spec): + """Test that exclude_data_source_names is forwarded to the teardown call""" + mock_admin_client = MagicMock() + mock_hco = MagicMock() + mock_hco.instance.spec = {"enableCommonBootImageImport": True} + mock_namespace = MagicMock() + mock_dics = [MagicMock()] + exclude_names = {"custom-datasource"} + + gen = disable_common_boot_image_import_hco_spec( + mock_admin_client, mock_hco, mock_namespace, mock_dics, exclude_data_source_names=exclude_names + ) + next(gen) + + try: + next(gen) + except StopIteration: + pass + + mock_enable_spec.assert_called_once_with( + hco_resource=mock_hco, + admin_client=mock_admin_client, + namespace=mock_namespace, + exclude_data_source_names=exclude_names, + ) + @patch("utilities.hco.enable_common_boot_image_import_spec_wait_for_data_import_cron") @patch("utilities.hco.wait_for_deleted_data_import_crons") @patch("utilities.hco.update_common_boot_image_import_spec") @@ -836,6 +865,39 @@ def test_enable_spec( exclude_data_source_names=None, ) + @patch("utilities.hco.wait_for_hco_conditions") + @patch("utilities.hco.wait_for_ssp_conditions") + @patch("utilities.hco.wait_for_at_least_one_auto_update_data_import_cron") + @patch("utilities.hco.update_common_boot_image_import_spec") + @patch("utilities.hco.Namespace") + @patch("utilities.hco.verify_boot_sources_reimported", return_value=True) + def test_enable_spec_propagates_exclude_data_source_names( + self, + mock_verify_boot, + mock_namespace_class, + mock_update_spec, + mock_wait_dic, + mock_wait_ssp, + mock_wait_hco, + ): + """Test that exclude_data_source_names is forwarded to verify_boot_sources_reimported""" + mock_hco = MagicMock() + mock_hco.namespace = "openshift-cnv" + mock_admin_client = MagicMock() + mock_namespace = MagicMock() + exclude_names = {"custom-datasource"} + + enable_common_boot_image_import_spec_wait_for_data_import_cron( + mock_hco, mock_admin_client, mock_namespace, exclude_data_source_names=exclude_names + ) + + mock_verify_boot.assert_called_once_with( + admin_client=mock_admin_client, + namespace=mock_namespace.name, + consecutive_checks_count=1, + exclude_data_source_names=exclude_names, + ) + class TestUpdateCommonBootImageImportSpec: """Test cases for update_common_boot_image_import_spec function""" From e7aef783c3e157406155645919ffbd9c79abdebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Wed, 10 Jun 2026 13:03:37 +0200 Subject: [PATCH 7/8] Add type hints to modified HCO boot image import functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 --- utilities/hco.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/utilities/hco.py b/utilities/hco.py index ee648c4461..1565debb68 100644 --- a/utilities/hco.py +++ b/utilities/hco.py @@ -1,6 +1,8 @@ import json import logging +from collections.abc import Collection, Generator from contextlib import contextmanager +from typing import TYPE_CHECKING from kubernetes.dynamic.exceptions import NotFoundError, ResourceNotFoundError from ocp_resources.cdi import CDI @@ -37,6 +39,10 @@ ) from utilities.storage import verify_boot_sources_reimported +if TYPE_CHECKING: + from kubernetes.dynamic import DynamicClient + from ocp_resources.data_import_cron import DataImportCron + LOGGER = logging.getLogger(__name__) DEFAULT_HCO_PROGRESSING_CONDITIONS = { @@ -348,12 +354,12 @@ def wait_for_hco_version(client, hco_ns_name, cnv_version): def disable_common_boot_image_import_hco_spec( - admin_client, - hco_resource, - golden_images_namespace, - golden_images_data_import_crons, - exclude_data_source_names=None, -): + admin_client: DynamicClient, + hco_resource: HyperConverged, + golden_images_namespace: Namespace, + golden_images_data_import_crons: list[DataImportCron], + exclude_data_source_names: Collection[str] | None = None, +) -> Generator[None]: if hco_resource.instance.spec[ENABLE_COMMON_BOOT_IMAGE_IMPORT]: update_common_boot_image_import_spec( hco_resource=hco_resource, @@ -373,8 +379,11 @@ def disable_common_boot_image_import_hco_spec( def enable_common_boot_image_import_spec_wait_for_data_import_cron( - hco_resource, admin_client, namespace, exclude_data_source_names=None -): + hco_resource: HyperConverged, + admin_client: DynamicClient, + namespace: Namespace, + exclude_data_source_names: Collection[str] | None = None, +) -> None: hco_namespace = Namespace(name=hco_resource.namespace) update_common_boot_image_import_spec( hco_resource=hco_resource, From 1c7104b17f4e0c8d0e51977596505331c030eed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Mon, 22 Jun 2026 13:08:04 +0200 Subject: [PATCH 8/8] Address CodeRabbit review: type hint, docstring fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramón Lobillo Co-Authored-By: Claude Opus 4.6 --- .../hco_enablement_golden_image_updates/conftest.py | 1 + utilities/hco.py | 4 ++-- utilities/storage.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py index 5ef8bed9bd..e7a38ea853 100644 --- a/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py +++ b/tests/install_upgrade_operators/hco_enablement_golden_image_updates/conftest.py @@ -124,6 +124,7 @@ def disabled_boot_image_import_excluding_custom_datasource( golden_images_namespace, golden_images_data_import_crons_scope_function, ): + """Disable common boot image import, skipping verification of the custom DataSource.""" yield from disable_common_boot_image_import_hco_spec( admin_client=admin_client, hco_resource=hyperconverged_resource_scope_function, diff --git a/utilities/hco.py b/utilities/hco.py index 1565debb68..46d7b71e74 100644 --- a/utilities/hco.py +++ b/utilities/hco.py @@ -1,6 +1,6 @@ import json import logging -from collections.abc import Collection, Generator +from collections.abc import Collection, Iterator from contextlib import contextmanager from typing import TYPE_CHECKING @@ -359,7 +359,7 @@ def disable_common_boot_image_import_hco_spec( golden_images_namespace: Namespace, golden_images_data_import_crons: list[DataImportCron], exclude_data_source_names: Collection[str] | None = None, -) -> Generator[None]: +) -> Iterator[None]: if hco_resource.instance.spec[ENABLE_COMMON_BOOT_IMAGE_IMPORT]: update_common_boot_image_import_spec( hco_resource=hco_resource, diff --git a/utilities/storage.py b/utilities/storage.py index 933f83a50c..9a38fb1cc7 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -1138,7 +1138,7 @@ def verify_boot_sources_reimported( When None, all DIC-managed DataSources are verified. Returns: - True if all DataSources reached Ready=True otherwise false + True if all non-excluded DIC-managed DataSources reached Ready=True, otherwise False """ try: for data_source in get_data_sources_managed_by_data_import_cron(client=admin_client, namespace=namespace):