X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1e4630ddb8015d72978aae1be334cce2f8ca20d4..525e81bdbe18ea369f5a61a713e743608bab2e42:/services/api/app/models/node.rb?ds=sidebyside diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb index c8b463696b..f384ba582b 100644 --- a/services/api/app/models/node.rb +++ b/services/api/app/models/node.rb @@ -20,10 +20,14 @@ class Node < ArvadosModel # Only a controller can figure out whether or not the current API tokens # have access to the associated Job. They're expected to set # job_readable=true if the Job UUID can be included in the API response. - belongs_to(:job, foreign_key: :job_uuid, primary_key: :uuid) + belongs_to :job, + foreign_key: 'job_uuid', + primary_key: 'uuid', + optional: true attr_accessor :job_readable UNUSED_NODE_IP = '127.40.4.0' + MAX_VMS = 3 api_accessible :user, :extend => :common do |t| t.add :hostname @@ -158,8 +162,8 @@ class Node < ArvadosModel LIMIT 1', # query label: 'Node.available_slot_number', - # [col_id, val] for $1 vars: - [[nil, Rails.configuration.Containers.MaxComputeVMs]], + # bind vars: + [MAX_VMS], ).rows.first.andand.first end @@ -175,7 +179,7 @@ class Node < ArvadosModel # as the new node. Clear the ip_address field on the stale # nodes. Otherwise, we (via SLURM) might inadvertently connect # to the new node using the old node's hostname. - stale_node.update_attributes!(ip_address: nil) + stale_node.update!(ip_address: nil) end end if hostname_before_last_save && saved_change_to_hostname? @@ -267,7 +271,7 @@ class Node < ArvadosModel !Rails.configuration.Containers.SLURM.Managed.DNSServerConfTemplate.to_s.empty? and !Rails.configuration.Containers.SLURM.Managed.AssignNodeHostname.empty?) - (0..Rails.configuration.Containers.MaxComputeVMs-1).each do |slot_number| + (0..MAX_VMS-1).each do |slot_number| hostname = hostname_for_slot(slot_number) hostfile = File.join Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir, "#{hostname}.conf" if !File.exist? hostfile