Skip to content

Sort issue, continuesly update of values because of wrong order #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
trefzer opened this issue Apr 9, 2025 · 0 comments
Open

Sort issue, continuesly update of values because of wrong order #85

trefzer opened this issue Apr 9, 2025 · 0 comments

Comments

@trefzer
Copy link
Contributor

trefzer commented Apr 9, 2025

The sort function in lib/puppet_x/libvirt/sort_elements.rb tries to have equal XML for the output of the virsh command and the XML generated by the templates so we can diff that to see if we need to update.

The sort_elements is a recursive function sorting all XML elements by it's name. For Arrays elements which share the same name, this fails since the name is equal for each element. In this case you need to adapt the order of the Array used to generate the XML (eg. networks with portgroups and several vlans in a portgroup is such a case). Mostly this happens if you manually use virsh to edit/update and afterward adapt your'e puppet manifest.

Reference:
#75 tried to fix this for portgroups but was reverted since this should not be fixed in the provider but in the sort_elements function.

Workaround:
Adapt the order of Array in your'e manifest to match the order from the virsh command (as seen in the diff).

trefzer added a commit that referenced this issue Apr 9, 2025
…or portgroups inside XML"

This partly reverts commit 4c55908 (#75).

The part 'human readable diff' is kept, the part 'correct sort...' is reverted.

Fixing the sort in the provider only is the wrong approach. This module uses
the function defined in lib/puppet_x/libvirt/sort_elements.rb to
have equal XML's to compare. The sort_elements function is used in the provider
to ensure sorting of the 'is' part. The 'should' part is sorted using
the function libirt::normalxml on the template XML output.

See Bug #85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant