fix: Return early to avoid adding empty groups.

If no VMIs were found in a namespace then return early to avoid adding
empty groups.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2024-04-03 17:26:49 +02:00
parent ecb285764a
commit 3560818167

View File

@@ -448,6 +448,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)