-
Notifications
You must be signed in to change notification settings - Fork 50
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
Empty 'parameters' array in json output #48
Comments
Looks like you can also just drop the ".authorized" off the end and it works.
|
Updated to 1.16 and ran into this again, and can confirm that what @markt-uom says is true - dropping the '.authorized' makes all my parameters appear in the json output passed to foreman-hooks |
Still need to do this workaround on Foreman 1.17 |
Still need to do this workaround on Foreman 1.18 |
Still valid on Foreman 1.19. |
@achevalet can you tell me more about the request you are doing? What effective user is the call which is causing the hook to trigger? Is that a super admin or regular admin? Can you try this with super admin? |
@lzap I'm using a super admin. After creating/deleting the host, the json does not show host parameters in 'parameters' or 'all_parameters' keys:
all_parameters show only inherited parameters (from hostgroup, subnet etc). If I drop the ".authorized" as described above, it shows my host param as below (for create only):
|
For the record, the change you refer to is: index 7bd22a0fa..70f6e9147 100644
--- a/app/views/api/v2/hosts/main.json.rabl
+++ b/app/views/api/v2/hosts/main.json.rabl
@@ -43,7 +43,7 @@ end
if @parameters
node do |host|
- { :parameters => partial("api/v2/parameters/index", :object => host.host_parameters.authorized) }
+ { :parameters => partial("api/v2/parameters/index", :object => host.host_parameters) }
end
end @ares any ideas why |
What should this authorized call do? This does not specify any permission, so it find all parameters user has any parameter permission to. IMHO the correct use here would be |
@achevalet are you using postcreate/postupdate? It works for me, I do see all params:
Please try again with postcreate/postupdate, I do see all params. Help me to reproduce this. The |
Yes, I can reproduce the same. I see all params with postcreate/postupdate but I don't see them with create/destroy/postdestroy. |
But that's why we created post-versions! They technically cannot contain it because it's too early in the orchestration. Use post versions, we know this is a regression that's why we created them. |
Do you see them in |
This confuses me since the parameters are indeed available in both 'create' and 'destroy' if you remove the 'authorized' bit in the code. Since postcreate and postupdate, from what I understand, cannot trigger rollback on errors they dont fit my usecase. I use hooks, among other things, to validate input of specific parameters. If those parameters are not correct the orchestration needs to halt and get rolled back. |
I don't know, maybe @orrabin can jump in and provide more info about why not all parameters are showing up. This looks like a regression. |
No, I don't see them in destroy and postdestroy. |
Upgrade to 1.19 today and was reminded of this issue. Tried to set right before my hook script errors out due to it not finding expected data, but that line is not helping much. The only mentioned user in the logs is my own user ( I'm back to removing the |
same thing in 1.24, still have to edit the rabl file to get all parameters available to my hook scripts. |
This is still a problem in 2.3, and now, besides adjusting the
which is a new addition for the 'global registration' feature. Is there really no proper way to get host parameters passed to foreman hooks in |
For the record, we are working on https://github.com/theforeman/foreman_webhooks which will provide same functionality but with much better interface. Whole model is exposed in ERB template so you can render your JSON as you want. Package for 2.3 should land in the upcoming weeks. |
Related to #43, which partly solved the problem but is now closed.
The json output passed to my hook scripts are missing data - the 'parameters' array is empty. If I apply the workaround mentioned in the issue #43 the parameters array is populated as expected though.
The text was updated successfully, but these errors were encountered: