Skip to content

Commit e15b394

Browse files
vakwetuclaude
authored andcommitted
[multiple] Uniquify OSDPD names per deployment run
An OpenStackDataPlaneDeployment (OSDPD) is an immutable record of a single deployment run. Once its Status.Deployed is true, the operator short-circuits reconciliation with "Already deployed" and will never re-run jobs, even if the referenced nodesets have since been updated with new content (e.g. new SSH keys, new node config). When ci-framework re-applies a deployment stage with oc apply and the OSDPD already exists from a previous run, the operator ignores it. Meanwhile the nodeset operator resets DeploymentReady=False because it detects that the nodeset"s generation has advanced since the last deployment. This produces a permanent deadlock: the nodeset waits for a deployment that will never run, and the wait condition times out after 60 minutes. The correct model is: one OSDPD per deployment *run*, not per nodeset. Fix by auto-generating a timestamp suffix (YYYYMMDDHHMMSS) once at the start of the first deployment stage and appending it to the name of every OpenStackDataPlaneDeployment resource found in the kustomize build output before applying it. The suffix is stable within a single ansible run (so both edpm-deployment and edpm-deployment2 share the same suffix) but differs across runs, producing names like: edpm-deployment-20260313215236 edpm-deployment-20260314093012 Old OSDPDs are left in place as an audit trail of past runs. The operator only acts on the new CR, so the deadlock cannot occur. The suffix can be pinned by setting cifmw_kustomize_deploy_osdpd_suffix explicitly (useful for idempotent re-runs of the same logical deployment). Leave it empty (the default) for automatic timestamp generation. Signed-off-by: Ade Lee <alee@redhat.com> Co-Authored-By: Claude <noreply@anthropic.com> Made-with: Cursor
1 parent d487997 commit e15b394

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

roles/kustomize_deploy/defaults/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ cifmw_kustomize_deploy_dp_dest_file: >-
218218
219219
# timeouts and retry configuration
220220

221+
222+
# Suffix appended to OpenStackDataPlaneDeployment resource names when applying
223+
# a deployment stage. Each run produces a uniquely named OSDPD, preventing the
224+
# "Already deployed" deadlock that occurs when an existing OSDPD with
225+
# Status.Deployed=true is re-applied on subsequent runs.
226+
# When empty (the default), a timestamp is auto-generated once at the start of
227+
# the first deployment stage and reused for all subsequent stages in the same
228+
# run, so all OSDPDs in a given run share the same suffix.
229+
# Set explicitly to pin a known value (e.g. for idempotent re-runs).
230+
cifmw_kustomize_deploy_osdpd_suffix: ""
231+
221232
cifmw_kustomize_deploy_delay: 10
222233
cifmw_kustomize_deploy_retries_subscription: 90
223234
cifmw_kustomize_deploy_retries_install_plan: 60

roles/kustomize_deploy/tasks/execute_step.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
- _tag_name not in _skip_tags
9494
- _tag_name_id not in _skip_tags
9595
block:
96+
- name: Generate OSDPD run suffix (once per play)
97+
when: _cifmw_kustomize_deploy_run_suffix is not defined
98+
ansible.builtin.set_fact:
99+
_cifmw_kustomize_deploy_run_suffix: >-
100+
{{
101+
cifmw_kustomize_deploy_osdpd_suffix
102+
if (cifmw_kustomize_deploy_osdpd_suffix | default('') | length > 0)
103+
else (lookup('pipe', 'date +%Y%m%d%H%M%S'))
104+
}}
105+
96106
- name: Ensure source files exists
97107
register: _src
98108
when:
@@ -241,6 +251,30 @@
241251
content: "{{ _kustomize_output.stdout }}"
242252
mode: "0644"
243253

254+
255+
- name: "Uniquify OpenStackDataPlaneDeployment names in {{ stage.path }}"
256+
when: _cifmw_kustomize_deploy_run_suffix | default('') | length > 0
257+
changed_when: "'Renamed:' in _rename_osdpd.stdout"
258+
register: _rename_osdpd
259+
ansible.builtin.shell:
260+
executable: /bin/bash
261+
cmd: |
262+
python3 - << 'PYEOF'
263+
import yaml, sys
264+
path = "{{ _output }}"
265+
suffix = "{{ _cifmw_kustomize_deploy_run_suffix }}"
266+
with open(path) as f:
267+
docs = [d for d in yaml.safe_load_all(f) if d is not None]
268+
for doc in docs:
269+
if doc.get('kind') == 'OpenStackDataPlaneDeployment':
270+
name = doc['metadata']['name']
271+
if not name.endswith('-' + suffix):
272+
doc['metadata']['name'] = name + '-' + suffix
273+
print('Renamed: ' + name + ' -> ' + doc['metadata']['name'])
274+
with open(path, 'w') as f:
275+
yaml.dump_all(docs, f, default_flow_style=False)
276+
PYEOF
277+
244278
- name: "Store kustomized content in artifacts for {{ stage.path }}"
245279
ansible.builtin.copy:
246280
remote_src: true

0 commit comments

Comments
 (0)