Skip to content

[libvirt_manager] Add parent_group key for libvirt layouts#3925

Draft
michburk wants to merge 1 commit into
openstack-k8s-operators:mainfrom
michburk:libvirt-parent-groups
Draft

[libvirt_manager] Add parent_group key for libvirt layouts#3925
michburk wants to merge 1 commit into
openstack-k8s-operators:mainfrom
michburk:libvirt-parent-groups

Conversation

@michburk
Copy link
Copy Markdown
Contributor

Allow VM types to declare a parent_group key. Hosts are added to the parent group at add_host time so that groups like 'computes' are populated before dependent roles check group membership. A parent group inventory file is also written to reproducer-inventory/ for subsequent playbook runs.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 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 fultonj 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

@michburk michburk marked this pull request as ready for review May 15, 2026 20:14
@michburk michburk requested a review from a team May 18, 2026 12:03
Copy link
Copy Markdown
Contributor

@nemarjan nemarjan left a comment

Choose a reason for hiding this comment

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

LGTM in general, just some questions.

Comment thread roles/libvirt_manager/tasks/deploy_layout.yml Outdated
{{
_cifmw_libvirt_manager_layout.vms |
dict2items |
selectattr('value.parent_group', 'defined') |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(non-blocking): Since selectattr('value.parent_group', 'defined') only checks key existence, would an explicitly empty value like parent_group: "" slip through here? If so, it would produce a file named -group.yml and a nameless group?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That'd be an interesting situation, I'll test it and probably end up adding an explicit check for an empty string and fail in that case. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tested a setup with parent_group: '' and this did indeed create a -group.yml file, added an explicit check: rejectattr('value.parent_group', 'equalto', '') to not create this file. Other parts of this patch treat an empty value as falsey and don't do anything if '' is supplied as a parent group, so rejecting here treats it as if there were no parent group field at all.

If you think parent_group: '' should produce an error early on instead, I wouldn't mind refactoring to handle it that way.

@michburk
Copy link
Copy Markdown
Contributor Author

Also added a check to the Craft patch for cifmw_networking_definition task to skip generating group-template entries for child VM types when their parent_group matches an existing VM type in the libvirt layout.

My testing used two child VM types (compute94 and compute96) both setting parent_group: computes, with no compute group defined in the libvirt layout. This worked fine and should be unaffected by this change (re-testing now).

Nemanja's comment prompted me to test a layout with both a regular compute type and a compute96 child with parent_group: computes. This failed because the old logic generated entries for both computes and compute96s with the same networks. Since parent_group adds compute96 nodes to the computes Ansible group, the networking mapper saw those nodes in two groups that both defined the same network and rejected the duplicate.

Allow libvirt layout VM types to declare a parent_group field so that
multiple subtypes (e.g. compute94, compute96) are aggregated under a
shared inventory group (e.g. computes) while remaining independently
targetable via their subtype groups.

Changes:
- add_vm_to_inventory: add hosts to both subtype and parent groups
- generate_networking_data: resolve effective group via parent_group,
  aggregate sibling amounts into a single networking group-template
- all-inventory.yml.j2: emit parent group with children entries

Generated-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Michael Burke <michburk@redhat.com>
@michburk michburk force-pushed the libvirt-parent-groups branch from d202b36 to 8a9d4a5 Compare May 19, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants