Skip to content

unbound: migrate overrides support to MVC - #5488

Merged
AdSchellevis merged 4 commits into
opnsense:masterfrom
swhite2:unbound_overrides
Jan 24, 2022
Merged

unbound: migrate overrides support to MVC#5488
AdSchellevis merged 4 commits into
opnsense:masterfrom
swhite2:unbound_overrides

Conversation

@swhite2

@swhite2 swhite2 commented Jan 18, 2022

Copy link
Copy Markdown
Member

This PR moves the legacy Unbound->Overrides section to the new MVC model, enabling it for use with the API.

A couple of things to note:

  • This commit changes the FieldType HostnameField to now also accept wildcard entries (*). Default for this is false, so no impact.
  • Adds a template helper which retrieves the current configured IP Address of an interface, useful for non-static assignments as they are not stored in config.
  • Adds a template test in src/opnsense/service/modules/template.py to allow for regex checking in a template.
  • While most of the relevant code from unbound.inc has been deleted, checking the DHCP configured static map (both Ipv4 and Ipv6) and converting this to the relevant local-data sections for Unbound is still done by the unbound_add_host_entries_dhcp() function due to stringent IPv6 address-checking. It now writes this to a seperate include (host_entries_dhcp.conf).
    To avoid a huge template with too much logic in it, generating the config is still done by unbound.inc, it, however, now uses the base model methods to achieve this.
  • Provides a migration from host & domain overrides in the legacy config section to the OPNsense/Unbound section.
  • Addresses API unbound dns override #5392

@AdSchellevis AdSchellevis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@swhite2 some small remarks, but looks good. I haven't tried it on my end yet, but looking at the code I don't expect huge issues to be honest

Comment thread src/opnsense/mvc/app/models/OPNsense/Unbound/ACL/ACL.xml Outdated
Comment thread src/opnsense/mvc/app/models/OPNsense/Unbound/Menu/Menu.xml Outdated
Comment thread src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php Outdated
Comment thread src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php Outdated
Comment thread src/opnsense/service/modules/addons/template_helpers.py Outdated
@swhite2

swhite2 commented Jan 24, 2022

Copy link
Copy Markdown
Member Author

@AdSchellevis Thanks for the review, the latest commit addresses all of the above remarks.

@@ -0,0 +1,17 @@
{% if not helpers.empty('OPNsense.unboundplus.domains.domain') %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

personally would prefer leaving the "unboundplus" namespace for default "unbound" if we are going to migrate anyway

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Wouldn't this require a larger change beyond the scope of this PR? Just my 2 cents.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure if model renames are a good idea for general model migration behaviour reasons (@AdSchellevis would know better) but except this the change would entail changing a few configuration template lines and that isn't unreasonable to do so during the migration taking place here anyway. M1_0_0.php already contains the code to be used for this. It takes the contents from the old config location and moves it to the new model.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. Impact doesn't seem to be that high. I'd also like to know what @AdSchellevis thinks about model renaming.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@swhite2 @fichtner I don't mind that much about renaming the model, but to limit impact it might be better to test and merge this first and add another model version explicitly for the move. race conditions may lead to unintended side affects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only concern is that templates need to be changed after adding more of them to migrate but the end result is still I can hope for 😊

@AdSchellevis
AdSchellevis merged commit 161d246 into opnsense:master Jan 24, 2022
@AdSchellevis

Copy link
Copy Markdown
Member

@swhite2 just tried it on my end, seems to work fine. thanks!

AdSchellevis pushed a commit that referenced this pull request Jan 24, 2022
* unbound: overrides: migrate to mvc model
* unbound: overrides: generate host_entries via model, revert template generation
* unbound: overrides migration: fix missing include
* unbound: overrides: clean up

Co-authored-by: Stephan de Wit <stephan.de.wit@deciso.com>
@fichtner fichtner changed the title unbound: overrides: migrate to mvc model unbound: migrate overrides to MVC Feb 14, 2022
@fichtner fichtner changed the title unbound: migrate overrides to MVC unbound: migrate overrides support to MVC Feb 14, 2022
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