enhancement: add instance info as Libvirt metadata #11061
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds
<metadata>
section to the domain XML of the virtual machine.It is useful when the additional instance info is needed from within the compute host,
for example to use it with a monitoring exporter that would label the virtual machine with the additional information.
The method that generates the metadata object is defined in the
HypervisorGuruBase
class as protected, so it can be used in all its children classes. Currently I've only used it in theKVMGuru
because I do not have any other hypervisor kind to test this on.Additionally, some dead code that looks to be half-finished, was removed, namely
LibvirtVMDef.java:
public class MetadataDef
and the references to it. Kindly check this part, perhaps I accidentally remove something that was obscurely used by something.Fixes: #6695
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
The metadata has the following format:
How Has This Been Tested?
I specifically put an emphasis on compatibility with the previous versions, so having a mgmt server with this feature/agent without this feature and vice versa will not crash the VM startup.
These are the tests that I preformed:
Both the Mgmt servers and the Nodes contain this patch:
<cloudstack:resource_tags/>
<cloudstack:host_tags/>
<cloudstack:project uuid=""/>
Mgmt server contains the patch, the node does not contain the patch:
Mgmt server does not contain the patch, the host contains the patch:
How did you try to break this feature and the system with this change?
I specifically checked for the empty values in my tests: service offering without tags, no resource tags, no project etc as those look to be the most dangerous parts.
Plus, the code checks for null value everywhere, and uses "unknown" default value when null is occurred.