From c73bdb373ebcc9baecf25770b50752680249cd4d Mon Sep 17 00:00:00 2001 From: Johnathan Kupferer Date: Tue, 17 Nov 2026 11:02:11 -0500 Subject: [PATCH] GPTEINFRA-18745 - Fix to pass sandbox_api_lab_key parameter - Fix ResourceProvider to add `sandbox_api_lab_key` parameter for virtual CIs using tenant items. - python-client-library-v0.3.10 - agnosticv-operator-v2.8.5 --- agnosticv-operator/operator/operator.py | 12 +++++++++--- agnosticv-operator/requirements.txt | 2 +- .../src/babylon_async/agnosticvcomponent.py | 19 +++++++++++++++++-- helm/values.yaml | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/agnosticv-operator/operator/operator.py b/agnosticv-operator/operator/operator.py index bab3f89f0..7e90394a9 100644 --- a/agnosticv-operator/operator/operator.py +++ b/agnosticv-operator/operator/operator.py @@ -206,7 +206,9 @@ async def manage_agnosticv_component(agnosticv_component: AgnosticVComponent, lo logger ) resource_provider = await manage_resource_provider( - agnosticv_component, logger + agnosticv_component, + linked_agnosticv_components, + logger ) tenant_cluster_pool = await manage_tenant_cluster_pool( agnosticv_component, @@ -335,9 +337,13 @@ async def manage_catalog_item( return catalog_item async def manage_resource_provider( - agnosticv_component: AgnosticVComponent, logger + agnosticv_component: AgnosticVComponent, + linked_agnosticv_components: List[AgnosticVComponent], + logger ) -> ResourceProvider|None: - resource_provider_definition = agnosticv_component.get_resource_provider_definition() + resource_provider_definition = agnosticv_component.get_resource_provider_definition( + linked_agnosticv_components=linked_agnosticv_components, + ) if resource_provider_definition is None: return None resource_provider_name = resource_provider_definition['metadata']['name'] diff --git a/agnosticv-operator/requirements.txt b/agnosticv-operator/requirements.txt index e8e945153..de22b5211 100644 --- a/agnosticv-operator/requirements.txt +++ b/agnosticv-operator/requirements.txt @@ -13,4 +13,4 @@ pygit2==1.19.0 pytimeparse==1.1.8 str2bool==1.1 StringGenerator==0.5.1 -babylon_async @ git+https://github.com/redhat-cop/babylon.git@python-client-library-v0.3.9#subdirectory=client/python/babylon_async +babylon_async @ git+https://github.com/redhat-cop/babylon.git@python-client-library-v0.3.10#subdirectory=client/python/babylon_async diff --git a/client/python/babylon_async/src/babylon_async/agnosticvcomponent.py b/client/python/babylon_async/src/babylon_async/agnosticvcomponent.py index 7aa7f8682..151cb830b 100644 --- a/client/python/babylon_async/src/babylon_async/agnosticvcomponent.py +++ b/client/python/babylon_async/src/babylon_async/agnosticvcomponent.py @@ -844,7 +844,9 @@ def get_catalog_item_definition(self, return definition - def get_resource_provider_definition(self) -> Mapping|None: + def get_resource_provider_definition(self, + linked_agnosticv_components: List[AgnosticVComponent], + ) -> Mapping|None: """Get ResourceProvider definition Return None if item is an exernal url.""" # FIXME - catalog_meta should not impact anarchy governor creation. @@ -1134,7 +1136,14 @@ def get_resource_provider_definition(self) -> Mapping|None: definition['spec']['statusSummaryTemplate']['catalog_item_name'] = self.name definition['spec']['statusSummaryTemplate']['catalog_item_namespace'] = self.catalog_item_namespace + linked_component_has_tenant_cluster = False for idx, linked_component in enumerate(self.linked_components): + # Get linked AgnosticVComponent from linked_agnosticv_components + linked_agnosticv_component = None + for item in linked_agnosticv_components: + if item.name == linked_component.component_name: + linked_agnosticv_component = item + linked_resource_provider = { "name": linked_component.component_name, "waitFor": f"current_state_{idx} == 'started'", @@ -1155,6 +1164,11 @@ def get_resource_provider_definition(self) -> Mapping|None: ] } + # Pass any sandbox_api_lab_key to any linked component that uses a tenant cluster + if linked_agnosticv_component is not None and linked_agnosticv_component.has_tenant_cluster: + linked_component_has_tenant_cluster = True + linked_resource_provider['parameterValues']['sandbox_api_lab_key'] = "{{sandbox_api_lab_key|default(omit)}}" + if linked_component.when: linked_resource_provider['when'] = linked_component.when definition['spec'].setdefault('linkedResourceProviders', []).append(linked_resource_provider) @@ -1248,7 +1262,7 @@ def get_resource_provider_definition(self) -> Mapping|None: # Pass sandbox_api_lab_key as var in AnarchySubject if set as parameter. # This allows the workshop manager to associate AnarchySubjects to TenantClusterPools. - if self.has_tenant_cluster: + if self.has_tenant_cluster or linked_component_has_tenant_cluster: definition['spec']['parameters'].append({ "name": "sandbox_api_lab_key", "allowUpdate": False, @@ -1260,6 +1274,7 @@ def get_resource_provider_definition(self) -> Mapping|None: } } }) + if self.has_tenant_cluster and self.deployer_type is not None: definition['spec']['override']['spec']['vars']['sandbox_api_lab_key'] = ( '{{resource_handle.parameter_values.sandbox_api_lab_key|default(omit)}}' ) diff --git a/helm/values.yaml b/helm/values.yaml index af1d3ec04..20521e2ae 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -23,7 +23,7 @@ agnosticv: operator: image: repository: quay.io/rhpds/babylon-agnosticv-operator - tag: v2.8.4 + tag: v2.8.5 pullPolicy: IfNotPresent resources: limits: