Skip to content

Conversation

@shafer
Copy link

@shafer shafer commented May 24, 2020

This is something I currently use on my VyOS install so I can take advantage of LUA scripts that alter the behaviour of the server.

You can find a few examples here: https://github.com/PowerDNS/pdns/tree/master/pdns/recursordist/examples

There isn't a phabricator for this work. If required to get this accepted I could setup an account and link this PR to a feature request.

@jjakob
Copy link
Contributor

jjakob commented May 24, 2020 via email

@shafer
Copy link
Author

shafer commented May 24, 2020

Ok. I can add a task next time. I'm an infrequent contributor and haven't been able to stay caught up with the new processes.

Would you suggest I close this PR? I'm just happy for the feature to wind up in rolling. I don't care how. :)

@dmbaturin
Copy link
Member

There's no need to close it. You can force push to the same branch, with correct commit descriptions.

@jjakob
Copy link
Contributor

jjakob commented May 24, 2020 via email

@shafer shafer force-pushed the add_dns_lua_script branch from a7519b9 to e59dd21 Compare May 24, 2020 22:46
@shafer shafer changed the title Adds support for configuring a lua script in PowerDNS T2508 Enable user to configure LUA script that alters recursor resolving May 24, 2020
@jjakob
Copy link
Contributor

jjakob commented May 25, 2020

  • I'd name the node 'lua-dns-script' to avoid confusion with 'lua-config-file' (TIL pdns-recursor has 2 different lua config files)
  • add the empty variable "lua_script": "", to default_config data
  • put a warning in the new node field like there is in dhcp-server *-parameters (e.g. "You must use a file suitable for use with pdns-recursor's lua-dns-script, any errors in the file will result in a service failure. Check the system log for errors after modifying.")

@shafer shafer force-pushed the add_dns_lua_script branch from e59dd21 to 9ee21fe Compare May 25, 2020 22:09
@shafer
Copy link
Author

shafer commented May 28, 2020

I made a comment in Phabricator already, but I'll make one here as well. I added the suggestions and pushed a new branch.

@jjakob
Copy link
Contributor

jjakob commented Jun 10, 2020

You haven't actually pushed any changes?

@shafer
Copy link
Author

shafer commented Jun 11, 2020

I shouldn't have said pushed a new branch. I pushed an updated branch. In the "Files changed" section of this PR I'm seeing the empty default, the warning language, and the node name change.

@jjakob
Copy link
Contributor

jjakob commented Jun 11, 2020

Well none of the issues I raised in the review are fixed, so the current code won't even work, that's why I suspect it's still waiting to be merged. Double check the comments in my review. To clarify, this was after the first comments that you mentioned (those changes were pushed, but the code still had issues so I added some more comments)

@shafer
Copy link
Author

shafer commented Jun 11, 2020

Based on the feedback in this comment I made changes. I don't see feedback other than that.

Here is a screenshot showing what I see. Which includes a new node name of lua-dns-script, a warning similar to making custom dhcpd changes, and the empty default.

Screenshot_2020-06-10_19-06-58

I'm at a loss to find other comments in this PR or in Phabricator that suggest code changes.

@jjakob
Copy link
Contributor

jjakob commented Jun 11, 2020

That's odd, the code comments are definitely showing here... I'm closing the current review and reopening it in case Github messed up somehow

@shafer
Copy link
Author

shafer commented Jun 11, 2020

Please let me know in a comment when you do. As of this comment I'm not seeing anything new yet.

query-local-address=0.0.0.0
query-local-address6=::

{% if lua_script -%}
Copy link
Contributor

@jjakob jjakob Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable doesn't exist, it's named lua_dns_script in the main script (the 'dns' dict variable keys are the variables in the jinja2 template)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this in latest push. I forgot to rename if in template after renaming it other places.

dns['allow_from'] = conf.return_values(['allow-from'])

if conf.exists('lua-dns-script'):
lua_dns_script = conf.return_value('lua-dns-script')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still an unneeded variable assignment, you can assign it directly to the end variable like this:
dns['lua_dns_script'] = conf.return_value('lua-dns-script')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware you can do this, but I was following the pattern already present in the code. My pref would be to leave it as-is and let a different phabricator efffort to clean/optimize handle it.

@jjakob
Copy link
Contributor

jjakob commented Jun 11, 2020

Figured it out, it was a PEBKAC on my part, the comments were "pending" until I actually clicked "start review"...

@shafer shafer force-pushed the add_dns_lua_script branch from 9ee21fe to 26c23b8 Compare June 11, 2020 14:49
@jjakob
Copy link
Contributor

jjakob commented Jun 12, 2020

@shafer one issue was fixed, the other comment wasn't - it'll still work that way, but I don't see the reason for the unnecessary intermediate local scope variable. Assign the result of conf.return_value to the dns dict key directly in one line.

@shafer shafer force-pushed the add_dns_lua_script branch from 26c23b8 to 7e2be8b Compare June 15, 2020 03:30
@shafer
Copy link
Author

shafer commented Jun 15, 2020

Maybe I didn't do something with the review I was supposed to. I commented that I did it that way because it matched the pattern. I've updated again to use the code that takes fewer lines, but doesn't match the pattern for cache_size or negative_ttl as examples.

@shafer shafer closed this Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants