Skip to content

Comments

[sushy_emulator] Fix list handling for VM instances#3678

Open
holser wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
holser:ansible-core-2.17.14_sushi
Open

[sushy_emulator] Fix list handling for VM instances#3678
holser wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
holser:ansible-core-2.17.14_sushi

Conversation

@holser
Copy link
Contributor

@holser holser commented Feb 12, 2026

Remove regex replacement that converted list to string format. The
variable should remain as a list for proper loop iteration in
Ansible 2.16+.

Co-Authored-By: Claude noreply@anthropic.com
Signed-off-by: Sergii Golovatiuk sgolovat@redhat.com

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign evallesp for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@holser holser requested a review from rebtoor February 12, 2026 11:47
@holser holser force-pushed the ansible-core-2.17.14_sushi branch from d26f7a6 to 54cf81a Compare February 12, 2026 12:07
@softwarefactory-project-zuul
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/06565e38a53248ac9155519606efd3f4

✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 54m 41s
✔️ podified-multinode-edpm-deployment-crc SUCCESS in 1h 22m 58s
✔️ cifmw-crc-podified-edpm-baremetal SUCCESS in 1h 39m 45s
cifmw-crc-podified-edpm-baremetal-minor-update FAILURE in 37m 03s
✔️ cifmw-pod-zuul-files SUCCESS in 4m 24s
✔️ noop SUCCESS in 0s
✔️ cifmw-pod-ansible-test SUCCESS in 7m 57s
✔️ cifmw-pod-pre-commit SUCCESS in 8m 06s
cifmw-molecule-reproducer FAILURE in 12m 12s
cifmw-molecule-sushy_emulator FAILURE in 18m 55s

{{ matching_vms }}
ansible.builtin.set_fact:
_cifmw_sushy_emulator_instances: "{{ _matching_vms | regex_replace('\n(?!.*\n)', ', ')}}"
_cifmw_sushy_emulator_instances: "{{ _matching_vms }}"
Copy link
Contributor

@hjensas hjensas Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the regex to convert this to a comma separated string, instead of a \n line-break reparated string. Because it is the input for sushy emulator config file:

SUSHY_EMULATOR_ALLOWED_INSTANCES = {{ _cifmw_sushy_emulator_instances }}

_matching_vms is of tpy string, not of type list.

hmm, so rethinking - the string would not be newline separated, it would be a ["uuid-0", "uuid-1", "uuid-2"] ?

so what we actually need is something like:

_cifmw_sushy_emulator_instances: "{{ _matching_vms | from_yaml }} or from_json ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so as

We have libvirt-uuids.yml with the following content

libvirt_uuid:
    cifmw-ocp-master-0: 17a164e9-46af-504d-b750-4d768f4b1b71
    cifmw-ocp-master-1: a91fb6bc-1bf2-532a-b3ef-4bdecda8a0dd
    cifmw-ocp-master-2: 8e6c659c-27df-5ead-bdf2-59b8dde77263
    cifmw-ocp-worker-0: f2db0152-6cdc-5cef-9294-f1248364389a

When we slurp data we get the following structure

        "cifmw_libvirt_manager_uuids": {
            "cifmw-ocp-master-0": "17a164e9-46af-504d-b750-4d768f4b1b71",
            "cifmw-ocp-master-1": "a91fb6bc-1bf2-532a-b3ef-4bdecda8a0dd",
            "cifmw-ocp-master-2": "8e6c659c-27df-5ead-bdf2-59b8dde77263",
            "cifmw-ocp-worker-0": "f2db0152-6cdc-5cef-9294-f1248364389a"
        }

In Generate list of filtered VMs task we set matching_vms as empty list by

matching_vms = []

then in for loop we add UUIDs to list of matching vms as

set _ = matching_vms.append(uuid)

so we get the following list

"_cifmw_sushy_emulator_instances": [
            "17a164e9-46af-504d-b750-4d768f4b1b71",
            "a91fb6bc-1bf2-532a-b3ef-4bdecda8a0dd",
            "8e6c659c-27df-5ead-bdf2-59b8dde77263",
            "f2db0152-6cdc-5cef-9294-f1248364389a"
        ]

after my change. We don't need to convert it to comma separated string as whole code is around list for _cifmw_sushy_emulator_instances variable. In roles/reproducer/tasks/generate_bm_info.yml we have the following code

{% if item.value in _cifmw_sushy_emulator_instances | default([]) %}

or roles/sushy_emulator/tasks/create_container.yml has

req = urllib.request.Request('http://localhost:8000/redfish/v1/Systems/{{ _cifmw_sushy_emulator_instances[0] }}');

@holser holser force-pushed the ansible-core-2.17.14_sushi branch from d79c2ac to 95eca9c Compare February 23, 2026 18:32
Remove regex replacement that converted list to string format. The
variable should remain as a list for proper loop iteration in
Ansible 2.16+.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Sergii Golovatiuk <sgolovat@redhat.com>
@holser holser force-pushed the ansible-core-2.17.14_sushi branch from 95eca9c to 2221d49 Compare February 23, 2026 18:36
# It is useful in a tenant environment where only some instances represent
# virtual baremetal.
SUSHY_EMULATOR_ALLOWED_INSTANCES = {{ _cifmw_sushy_emulator_instances }}
SUSHY_EMULATOR_ALLOWED_INSTANCES = '{{ _cifmw_sushy_emulator_instances | join(", ") }}'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we need CSV in template we should add it to template and operate lists in ansible code

@softwarefactory-project-zuul
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/8836ee39b1574d0d98c28b131b7794d5

✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 19m 26s
✔️ podified-multinode-edpm-deployment-crc SUCCESS in 1h 19m 08s
✔️ cifmw-crc-podified-edpm-baremetal SUCCESS in 1h 29m 01s
cifmw-crc-podified-edpm-baremetal-minor-update FAILURE in 2h 07m 13s
✔️ cifmw-pod-zuul-files SUCCESS in 5m 00s
✔️ noop SUCCESS in 0s
✔️ cifmw-pod-ansible-test SUCCESS in 27m 37s
✔️ cifmw-pod-pre-commit SUCCESS in 8m 26s
✔️ cifmw-molecule-reproducer SUCCESS in 16m 08s
✔️ cifmw-molecule-sushy_emulator SUCCESS in 19m 01s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants