diff --git a/plugins/inventory/kubevirt.py b/plugins/inventory/kubevirt.py index cf6e443..6f48ccf 100644 --- a/plugins/inventory/kubevirt.py +++ b/plugins/inventory/kubevirt.py @@ -461,6 +461,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): f"Error fetching VirtualMachineInstance list: {self.format_dynamic_api_exc(exc)}" ) from exc + if not vmi_list.items: + # Return early if no VMIs were found to avoid adding empty groups. + return + services = self.get_ssh_services_for_namespace(client, namespace) name = self._sanitize_group_name(name)