Skip to content

Commit 3397826

Browse files
committed
[update] Retag customContainerImages in OpenStackVersion CR during minor update
Starting with openstack-operator FR4 (openstack-k8s-operators/openstack-operator#1569, merged Oct 2025), the `OpenStackVersion` admission webhook rejects `targetVersion` changes when `spec.customContainerImages` are identical to those tracked for the previously deployed version. During the update flow, `set_openstack_containers` updates the operator CSV env vars with the new delorean tag, but nothing updates the `OpenStackVersion` CR's `customContainerImages` -- they still carry the tag from the initial greenfield deployment. When `update_services` later patches `targetVersion`, the webhook rejects the request because the custom images haven't changed. Add a step after `set_openstack_containers` that reads the current `customContainerImages` from the `OpenStackVersion` CR, replaces every image tag with the new delorean md5 hash, and patches the CR. This ensures the custom images reflect the new version before `targetVersion` is changed, satisfying the webhook and guaranteeing the update uses the correct container images. Assisted-by: Cursor (claude-4.6-opus-high) Signed-off-by: Roberto Alfieri <ralfieri@redhat.com>
1 parent bdf2911 commit 3397826

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

playbooks/update.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,48 @@
5353
name: set_openstack_containers
5454
when: cifmw_ci_gen_kustomize_values_deployment_version is not defined
5555

56+
- name: Update customContainerImages in OpenStackVersion CR with new tag
57+
when: cifmw_ci_gen_kustomize_values_deployment_version is not defined
58+
block:
59+
- name: Get the OpenStackVersion CR
60+
kubernetes.core.k8s_info:
61+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
62+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
63+
context: "{{ cifmw_openshift_context | default(omit) }}"
64+
api_version: core.openstack.org/v1beta1
65+
kind: OpenStackVersion
66+
namespace: "{{ cifmw_update_namespace | default('openstack') }}"
67+
register: _cifmw_update_osv_info
68+
69+
- name: Build retagged customContainerImages
70+
when:
71+
- _cifmw_update_osv_info.resources | length > 0
72+
- _cifmw_update_osv_info.resources[0].spec.customContainerImages is defined
73+
ansible.builtin.set_fact:
74+
_cifmw_update_retagged_images: >-
75+
{{
76+
_cifmw_update_osv_info.resources[0].spec.customContainerImages |
77+
to_json |
78+
regex_replace('(@sha256:[a-f0-9]+|:[a-zA-Z0-9._-]+)"',
79+
':' ~ cifmw_set_openstack_containers_tag ~ '"') |
80+
from_json
81+
}}
82+
83+
- name: Patch OpenStackVersion CR with retagged customContainerImages
84+
when: _cifmw_update_retagged_images is defined
85+
kubernetes.core.k8s:
86+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
87+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
88+
context: "{{ cifmw_openshift_context | default(omit) }}"
89+
api_version: core.openstack.org/v1beta1
90+
kind: OpenStackVersion
91+
name: "{{ _cifmw_update_osv_info.resources[0].metadata.name }}"
92+
namespace: "{{ cifmw_update_namespace | default('openstack') }}"
93+
state: patched
94+
definition:
95+
spec:
96+
customContainerImages: "{{ _cifmw_update_retagged_images }}"
97+
5698
- name: Sync repos for controller to compute
5799
hosts: computes
58100
gather_facts: true

0 commit comments

Comments
 (0)