theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
145 stars 162 forks source link

Add wait for repo metadata generation in export playbooks #1735

Closed Griffin-Sullivan closed 1 month ago

Griffin-Sullivan commented 1 month ago

Surely there's a better way to do this, but to summarize here's the issue:

  1. We make repo and then right after do an export in both these tests
  2. When the export is started the task for generating the repo metadata is still running (although it's pretty fast)
  3. Rerunning after a failure will work since the task is done by then. Adding a wait for 2 seconds achieves the same result.

Is there a more synchronous way to do this? Maybe wait for the task? I'm not sure if the metadata task is reported back when the repository create task is finished.

evgeni commented 1 month ago

Well, our modules already do wait for task completion if there is a "direct" task: https://github.com/theforeman/foreman-ansible-modules/blob/a7077cc1cf6fc2d6ac907072b82462b1368d3a95/plugins/module_utils/foreman_helper.py#L1193-L1196

So whatever does the generation is not properly reported as part of the task (maybe intentionally?)

I also see no task-related info in https://github.com/theforeman/foreman-ansible-modules/blob/develop/tests/test_playbooks/fixtures/repository-0.yml, so I'd just assume this is how it is today and merge your "sleep 2".