-
Notifications
You must be signed in to change notification settings - Fork 101
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 #16105 - Force DNS rebuild when provisioning discovered host #297
Conversation
[test] |
2cc8bc6
to
4f76415
Compare
Will take a look tomorrow, thanks! |
@@ -73,6 +73,7 @@ def update | |||
def perform_update(host, success_message = nil) | |||
Taxonomy.no_taxonomy_scope do | |||
::ForemanDiscovery::HostConverter.set_build_clean_facts(host) | |||
@host.primary_interface.discovery_queue_rebuild_dns unless @host.primary_interface.pending_dns_record_changes? |
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.
This code will not work with auto-provisioning, make sure it work in both ways. Anyways.
I think instead of calling this explicitly, we should create new after_validation :queue_dns_discovery
hook. In the hook method, check if we are converting from Discovered, like we do in other hooks, then queue it when necessary.
Add tests for normal and autoprovisioning please. And make the commit message shorter :-)
Example: module MyExtensions
extend ActiveSupport::Concern
included do
after_validation :queue_dns_rebuild
end
def queue_dns_rebuild
return unless errors.empty? && !Setting[:discovery_always_rebuild_dns]
return if new_record? # Discovered Hosts already exist, and new_records will break `find`
return unless type_changed? and ::Host::Base.find(self.id).type == "Host::Discovered"
# do your stuff here
end |
The code could be perhaps part of discovery's |
Mmm, maybe the same convention as the other orchestration concerns? |
@lzap updated the PR. |
@@ -31,6 +31,7 @@ def self.load_defaults | |||
self.set('discovery_facts_ipmi', N_("Regex to organize facts for ipmi section"), "", N_("IPMI facts")), | |||
self.set('discovery_lock', N_("Automatically generate PXE configuration to pin a newly discovered host to discovery"), false, N_("Lock PXE")), | |||
self.set('discovery_lock_template', N_("PXE template to be used when pinning a host to discovery"), 'pxelinux_discovery', N_("Locked template name"),nil,{ :collection => Proc.new {Hash[ProvisioningTemplate.all.map{|template| [template[:name], template[:name]]}]} }), | |||
self.set('discovery_always_rebuild_dns', N_("Force DNS entries creation when provisioning discovered host"), true, N_("Force DNS")), |
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.
Looks great. Why this is enabled by default? Normally, discovered hosts should not be added to DNS, thus I'd set this to false
.
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.
This only affects when you provision the host, not when it enters discovery, and in that case you always expect DNS to be created.
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.
This only affects when you provision the host, not when it enters discovery, and in that case you always expect DNS to be created.
Disregard my comment, this should be turned on by default.
Later,
Lukas #lzap Zapletal
What a coincidence, I just accepted my very first MyHeritage Instant Discovery e-mail when I noticed your domain. I am newcomer there. I was wondering if you could update http://projects.theforeman.org/projects/foreman/wiki/Who_Uses_Foreman (if that's valid and appropriate). Very nice patch indeed. Please do my smallish comments and I will test and merge it later this week. |
Sure! will do :) |
@lzap PR updated per your comments, and I've updated the "Who_Uses_Foreman" :) Thanks!! |
It work fine, in my environment I see:
The initial DNS deletion failed on proxy and returned 404 but this was not reason for rollback and the transaction continued. Which brings this question - do we want really to rebuild DNS (delete/add operations) or simply build DNS (add operation only)? I lean towards the latter to prevent such 404 errors. Or both maybe (make it a three state flag), because I would like to implement naming discovered hosts using the "deacon" gem we recently added (http://projects.theforeman.org/issues/16330). Explain me your use case - why you prefer rebuilding instead of building DNS entry? Do you create DNS name during discovery phase somehow? |
No specific reason. I used it because it is safe, and can overcome stale On Aug 26, 2016 3:57 PM, "Lukáš Zapletal" notifications@github.com wrote:
|
Merged as fe52972, thank you! |
No description provided.