Skip to content

Commit 5fb0f9c

Browse files
ccardenosaclaude
andcommitted
fix(hub_lockdown_capture): Correctly capture per-operator OperatorGroup names and specs
Bug: The role was capturing only the LAST OperatorGroup's name and spec for ALL operators, causing all operators to appear with 'global-operators' in lockdown JSON. Root Cause: Lines 92-135 computed _current_og_name and _current_og_spec in separate loops, overwriting the variables on each iteration. When building lockdown_operators (line 150-151), all operators received the last iteration's values. Fix: Move OG name and spec computation inline as task-level vars within the operator extraction loop. This ensures each subscription gets its correct OG based on its namespace. Impact: Before: All operators showed 'og_name': 'global-operators', 'og_spec': {} After: Each operator shows its actual OG (e.g., 'multicluster-engine', 'local-operator-group') This fix ensures lockdown JSON accurately reflects the deployed cluster state, enabling correct operator reinstallation from lockdown. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 53ea0bf commit 5fb0f9c

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

  • playbooks/telco-kpis/roles/hub_lockdown_capture/tasks

playbooks/telco-kpis/roles/hub_lockdown_capture/tasks/main.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,20 @@
8989
ansible.builtin.set_fact:
9090
lockdown_operators: []
9191

92-
- name: Compute operator group name for subscription
93-
ansible.builtin.set_fact:
92+
- name: Extract operator details from subscriptions
93+
vars:
9494
_current_og_name: >-
9595
{{
9696
operator_groups_raw.resources
97-
| selectattr('metadata.namespace', 'equalto', subscription_item.metadata.namespace)
97+
| selectattr('metadata.namespace', 'equalto', item.metadata.namespace)
9898
| map(attribute='metadata.name')
9999
| first
100100
| default('')
101101
}}
102-
loop: "{{ subscriptions_raw.resources }}"
103-
loop_control:
104-
loop_var: subscription_item
105-
label: "{{ subscription_item.spec.name }}"
106-
107-
- name: Compute operator group spec for subscription
108-
ansible.builtin.set_fact:
109102
_current_og_spec: >-
110103
{{
111104
operator_groups_raw.resources
112-
| selectattr('metadata.namespace', 'equalto', subscription_item.metadata.namespace)
105+
| selectattr('metadata.namespace', 'equalto', item.metadata.namespace)
113106
| map(attribute='spec')
114107
| first
115108
| default({})
@@ -121,20 +114,14 @@
121114
| ternary(
122115
{'targetNamespaces': (
123116
operator_groups_raw.resources
124-
| selectattr('metadata.namespace', 'equalto', subscription_item.metadata.namespace)
117+
| selectattr('metadata.namespace', 'equalto', item.metadata.namespace)
125118
| map(attribute='spec.targetNamespaces')
126119
| first
127120
| default([])
128121
)},
129122
{}
130123
)
131124
}}
132-
loop: "{{ subscriptions_raw.resources }}"
133-
loop_control:
134-
loop_var: subscription_item
135-
label: "{{ subscription_item.spec.name }}"
136-
137-
- name: Extract operator details from subscriptions
138125
ansible.builtin.set_fact:
139126
lockdown_operators: >-
140127
{{

0 commit comments

Comments
 (0)