-
Notifications
You must be signed in to change notification settings - Fork 226
Fixes #38241 - Extend userdata API by MAC address endpoint #912
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
Conversation
ekohl
left a comment
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.
Refs #34887
That issue has been closed and already a Fixed in release version that went out so you can't use Refs for that. Please open a new issue.
2cd7c55 to
9c711de
Compare
9c711de to
cc8044a
Compare
cc8044a to
4c295e8
Compare
|
Thanks a lot for the fast responses! @ekohl |
f38d5a1 to
9ec90d9
Compare
|
|
||
| get "/:mac/:kind" do |mac, kind| | ||
| log_halt(500, "Failed to retrieve #{kind} userdata template for #{params.inspect}: ") do | ||
| Proxy::Templates::UserdataProxyRequest.new.get([mac, kind], request.env, params) |
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.
Looking at the method this feels like an abuse of the API:
| def get(kind, env, params) |
Technically it may work since it calls flatten, but I really don't like flatten because it ends up being really unpredictable what gets called.
But that's probably not the real issue. If you look at ProxyRequest you can see it copies the parameters while removing a blacklist:
smart-proxy/modules/templates/proxy_request.rb
Lines 30 to 33 in 6624f2c
| opts = params.clone.merge(:url => template_url) | |
| BLACKLIST_PARAMETERS.each do |blacklisted_parameter| | |
| opts.delete(blacklisted_parameter) | |
| end |
Looking at that blacklist, we can see kind is in there:
| BLACKLIST_PARAMETERS = ['path', 'template', 'kind', 'hostgroup', 'splat', 'captures'] |
I suspect both mac and kind are in params. Not entirely sure what the correct thing to do here, but this whole API feels awkward.
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.
Alright, I see why hostgroup and template don't need to be added in the test - thanks!
However, to make this API feel less awkward I see two improvements currently:
a.) Add another function in UserdataProxyRequest to mitigate the flatten here?
Like a def get_mac and then put the mac as mandatory function parameter? But, this makes it less generic..
b.) Overwrite BLACKLIST_PARAMETERS when inheriting ProxyRequest and add mac there?
What do you think?
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.
@ekohl thoughts on the comment from Bastian?
Make the Smart Proxy Userdata API endpoint consistent with the Foreman API which was extended in #34887 (46ca3e70).
9ec90d9 to
a64822c
Compare
|
As I am currently running into this problem and the patch at least works, may I ask if we can get it in as a fix or even as a workaround we can later improve on? |
stejskalleos
left a comment
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.
🍏 LGTM
Tested with Foreman and it works, all the comments have been addressed, let's get this in.
|
Thanks @stejskalleos and @bastian-src :-) |
Extend the proxy API to match the userdata API of foreman: theforeman/foreman#9213