Merge branch 'master' into 4233-graph-job-stats
[arvados.git] / services / api / app / models / node.rb
index 40b78e90808e3534d8468a808fd2ef24310765a9..ab8b1974bc13db3e70be6187fc7c284c4e8a6c1f 100644 (file)
@@ -183,12 +183,17 @@ class Node < ArvadosModel
   # At startup, make sure all DNS entries exist.  Otherwise, slurmctld
   # will refuse to start.
   if @@dns_server_conf_dir and @@dns_server_conf_template and
-      !File.exists? (File.join(@@dns_server_conf_dir, hostname_for_slot(MAX_SLOTS-1)))
+      !File.exists? (File.join(@@dns_server_conf_dir, "#{hostname_for_slot(MAX_SLOTS-1)}.conf"))
     (0..MAX_SLOTS-1).each do |slot_number|
       hostname = hostname_for_slot(slot_number)
-      hostfile = File.join @@dns_server_conf_dir, hostname
+      hostfile = File.join @@dns_server_conf_dir, "#{hostname}.conf"
       if !File.exists? hostfile
-        dns_server_update(hostname, '127.40.4.0')
+        n = Node.where(:slot_number => slot_number).first
+        if n.nil? or n.ip_address.nil?
+          dns_server_update(hostname, '127.40.4.0')
+        else
+          dns_server_update(hostname, n.ip_address)
+        end
       end
     end
   end