mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-05-08 14:22:38 +00:00
fix(inventory): Fix inventory source caching
Fix inventory source caching by separating the fetching of objects and populating the inventory. This way objects can be fetched from the K8S API or from a configured cached and the cache related parameters on the plugin now actually work. The inventory source cache was tested with the ansible.builtin.jsonfile cache plugin and 100k hosts (~2G JSON file). Though it took a noticeable amount of time for the inventory plugin to run it worked fine and no failures could be observed. Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
@@ -10,9 +10,12 @@ ansible-inventory -i test.kubevirt.yml -y --list --output empty.yml "$@"
|
||||
ansible-playbook playbook.yml "$@"
|
||||
|
||||
ansible-inventory -i test.kubevirt.yml -y --list --output all.yml "$@"
|
||||
ansible-inventory -i test.cache.kubevirt.yml -y --list --output cache_before.yml "$@"
|
||||
ansible-inventory -i test.label.kubevirt.yml -y --list --output label.yml "$@"
|
||||
ansible-inventory -i test.net.kubevirt.yml -y --list --output net.yml "$@"
|
||||
|
||||
ansible-playbook cleanup.yml "$@"
|
||||
|
||||
ansible-inventory -i test.cache.kubevirt.yml -y --list --output cache_after.yml "$@"
|
||||
|
||||
ansible-playbook verify.yml "$@"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
plugin: kubevirt.core.kubevirt
|
||||
name: test
|
||||
namespaces:
|
||||
- default
|
||||
create_groups: true
|
||||
cache: true
|
||||
cache_plugin: ansible.builtin.jsonfile
|
||||
cache_connection: kubevirt-cache
|
||||
@@ -38,3 +38,16 @@
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- inv_net['all']['children']['label_app_test']['hosts'] | length == 1
|
||||
- name: Read cached inventory after VM creation
|
||||
ansible.builtin.include_vars:
|
||||
file: cache_before.yml
|
||||
name: inv_cache_before
|
||||
- name: Read cached inventory after VM deletion
|
||||
ansible.builtin.include_vars:
|
||||
file: cache_after.yml
|
||||
name: inv_cache_after
|
||||
- name: Assert cached inventories are populated
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- inv_cache_before == inv_all
|
||||
- inv_cache_before == inv_cache_after
|
||||
|
||||
Reference in New Issue
Block a user