Revision da5a9c4e
Added by Lukas Zapletal over 8 years ago
app/models/concerns/orchestration/dns.rb | ||
---|---|---|
status = failure(_("DNS A Records %s already exists") % dns_a_record.conflicts.to_sentence, nil, :conflict) if dns? and dns_a_record and dns_a_record.conflicting?
|
||
status = failure(_("DNS PTR Records %s already exists") % dns_ptr_record.conflicts.to_sentence, nil, :conflict) if reverse_dns? and dns_ptr_record and dns_ptr_record.conflicting?
|
||
not status #failure method returns 'false'
|
||
rescue Net::Error => e
|
||
if domain.nameservers.empty?
|
||
failure(_("Error connecting to system DNS server(s) - check /etc/resolv.conf"), e)
|
||
else
|
||
dns1, dns2 = domain.nameservers
|
||
failure(_("Error connecting to '%{domain}' domain DNS servers: %{dns1}, %{dns2} - check query_local_nameservers and dns_conflict_timeout settings") % {:domain => domain.try(:name), :dns1 => dns1, :dns2 => dns2}, e)
|
||
end
|
||
end
|
||
end
|
app/models/setting/provisioning.rb | ||
---|---|---|
self.set('libvirt_default_console_address', N_("The IP address that should be used for the console listen address when provisioning new virtual machines via Libvirt"), "0.0.0.0", N_('Libvirt default console address')),
|
||
self.set('update_ip_from_built_request', N_("Foreman will update the host IP with the IP that made the built request"), false, N_('Update IP from built request')),
|
||
self.set('use_shortname_for_vms', N_("Foreman will use the short hostname instead of the FQDN for creating new virtual machines"), false, N_('Use short name for VMs')),
|
||
self.set('dns_conflict_timeout', N_("Timeout for DNS conflict validation (in seconds)"), 3, N_('DNS conflict timeout')),
|
||
].each { |s| self.create! s.update(:category => "Setting::Provisioning")}
|
||
end
|
||
|
lib/net/dns.rb | ||
---|---|---|
# Returns: a new DNS record object, A or PTR accordingly
|
||
# We query DNS directly, as its faster then to query our own proxy.
|
||
def self.lookup(query, proxy, resolver = Resolv::DNS.new)
|
||
Timeout::timeout(3) do
|
||
Timeout::timeout(Setting[:dns_conflict_timeout]) do
|
||
if (query =~ Validations::IP_REGEXP)
|
||
n = resolver.getname(query).to_s
|
||
i = query
|
test/unit/orchestration/dns_test.rb | ||
---|---|---|
Nic::Managed.any_instance.stubs(:recreate_ptr_record).raises(StandardError, 'DNS test fail')
|
||
refute h.interfaces.first.rebuild_dns
|
||
end
|
||
|
||
test 'test_host_should_error_timeout_error_properly' do
|
||
if unattended?
|
||
h = FactoryGirl.create(:host, :with_dns_orchestration, :location => nil, :organization => nil)
|
||
Net::DNS::ARecord.any_instance.stubs(:conflicting?).returns(true)
|
||
Net::DNS::ARecord.any_instance.stubs(:conflicts).raises(Net::Error)
|
||
h.primary_interface.domain.stubs(:nameservers).returns(["1.2.3.4"])
|
||
h.primary_interface.send(:dns_conflict_detected?)
|
||
assert_match /^Error connecting .* DNS servers/, h.errors[:base].first
|
||
end
|
||
end
|
||
|
||
test 'test_host_should_error_timeout_error_properly' do
|
||
if unattended?
|
||
h = FactoryGirl.create(:host, :with_dns_orchestration, :location => nil, :organization => nil)
|
||
Net::DNS::ARecord.any_instance.stubs(:conflicting?).returns(true)
|
||
Net::DNS::ARecord.any_instance.stubs(:conflicts).raises(Net::Error)
|
||
h.primary_interface.domain.stubs(:nameservers).returns([])
|
||
h.primary_interface.send(:dns_conflict_detected?)
|
||
assert_match /^Error connecting to system DNS/, h.errors[:base].first
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #11709 - better error for DNS conflict timeouts