Apply Errata to a Content Host via incremental CV has to wait till Capsule sync of the CV finishes
Description of problem:
Having a Content Host registered to a Capsule and assigned to a Content View. If one wants to apply an errata outside the C.V. current content, incremental C.V. version is created (and published via Capsule (repo) sync to the Capsule automatically). So far so good.
But when I click to "Apply Errata to Content Hosts Immediately after publishing" checkbox, BulkAction to install the errata is scheduled independently to the C.V. (repo) sync to the Capsule, and thus the attempt to install that errata to the Content Host is made before the Capsule gets synced content with the errata. And thus the errata apply fails.
This limits usage of fast patching systems registered via Capsule, in general.
The BulkAction / errata apply task simply must wait for completion of all C.V. repos synces to all Capsules. This "wait for all these tasks completions" can be weakened e.g. to check synces of Capsules that have a Content Host we apply the errata to, only.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create & publish (& promote) a C.V. with some bigger repo (e.g. RHEL7 base one) with exclude filter to purge away an errata (I used "skip any errata released after date ..").
2. Have a Content Host registered via an external Capsule and associated to the Content View.
3. Find some errata from the repo that isnt in the Content View (in my case, it was RHSA-2017:1365). Try to apply it to this Content Host and check on the "Apply Errata to Content Hosts Immediately after publishing".
4. Wait until the task finishes.
5. Check if the errata was applied to the Content Host and check the Host's /var/log/messages