-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #21072 - build apipie cache after plugins #592
Conversation
Installation of the plugins can influence the API and the apipie cache needs to be refreshed after that.
Doesn't this mean that every single time the rake task is executed? I think that breaks idempotency. Not sure what the best solution here is but maybe add the notify in |
@ekohl I though puppet does the de-duplication, so I would hope it would run the rake only once, after all the dependencies were run. |
@ekohl, my intention was to declare the apipie:cache:index rake task in init.pp with Did the implementation deviated from my intent? It seemed to work during my testing. |
@iNecas oh you might be right since |
No, I don't think so. I didn't fully oversee the patch but I do think you should ensure it's before the service class. |
Could we also change apipie:cache:index to apipie:cache? While this helps hammer, people get 404 after clicking on API endpoints in /apidoc/... |
@ares any issue for this? In general the plugins should generate non-index parts of the cache during the build time and ship it with the package. There should be no need to rebuild the whole cache. Theoretically I can imagine resources such as host, that is extended by multiple plugins where the pre-build approach probably will fail but i'd like to see some real case to check if we can improve the process. |
@mbacovsky please see https://bugzilla.redhat.com/show_bug.cgi?id=1479900 and https://bugzilla.redhat.com/show_bug.cgi?id=1480563 If you could point me to an example where this happen for other plugin, I can check openscap and virt-who plugins, they might be missing this in spec. |
Two bugs in one patch: I'm sold :) |
If you can also fix the tests then I think this is a good improvement. |
@ekohl the tests were fixed. I removed the breaking test which was testing the cache is not build if the database is not managed because I think there is no relation between the two. diff --git a/manifests/init.pp b/manifests/init.pp
index 9397f3f..c023bd2 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -314,6 +314,7 @@ class foreman (
foreman::rake { 'apipie:cache:index':
timeout => 0,
}
+ ~> class { '::foreman::service': }
Class['foreman::repo']
~> class { '::foreman::install': } @ares I'd like to avoid re-building the whole cache. It is taking long time which was the reason we were moving as much as possible of it to the package build time. I checked the bug in openscap plugin and found out it is missing the cache build step done by |
Actually there was. The flag was there to ensure the rake task was not executed. This was done for users who have a cluster of webservers and only want to execute rake tasks on one. On the other hand I think that the apipie cache does make sense since it operates on local files. |
@ekohl that means all the webservers in the cluster use single DB? Even in that case I don't see the relation. The apipie:cache rake task has to be executed after db:migrate otherwise the rake would fail to load the rails env. Besides that there is no need for the DB as the apipie:cache task only builds static API documentation that is stored in the API controllers and saves it into |
@mbacovsky I know @timogoebel runs multiple webservers using a shared DB. Then web01 runs the crons and manage tasks while web02 and up don't run those. You're correct that @timogoebel can you confirm what I just said and how this would affect your setup? |
Thanks @mbacovsky, makes sense with the cache. |
@ekohl: Thanks for asking. I don't think, this will lead to any problems. However, I don't see why this is a problem in the first place. The apipie cache is also built after every plugin install by the rpms. Not sure about deb packages. |
@timogoebel this is good point. I have in my TODO to check if we can reduce cache rebuild to one per rpm transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only issue I can see is that if someone notifies Class[foreman]
it'll now rebuild the apipie cache where previously it didn't. Not sure how big an issue this is in practice. In puppet-katello we now notify Class[foreman::service]
so that shouldn't be an issue.
@mmoll mind having a look as well?
Seems like this one could be good to go? |
Could still use a review from @mmoll but I can't see any problem. |
I think this is fine, merged, díky @mbacovsky! |
Installation of the plugins can influence the API
and the apipie cache needs to be refreshed after that.