t.add :last_ping_at
t.add :slot_number
t.add :status
+ t.add :crunch_worker_state
end
api_accessible :superuser, :extend => :user do |t|
t.add :first_ping_at
super || @@domain
end
+ def crunch_worker_state
+ case self.info.andand[:slurm_state]
+ when 'alloc', 'comp'
+ 'busy'
+ when 'idle'
+ 'idle'
+ else
+ 'down'
+ end
+ end
+
def status
if !self.last_ping_at
if Time.now - self.created_at > 5.minutes
if o[:ping_secret] != self.info[:ping_secret]
logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.info[:ping_secret]}\""
- return nil
+ raise ArvadosModel::UnauthorizedError.new("Incorrect ping_secret")
end
self.last_ping_at = Time.now
if o[:ec2_instance_id]
if !self.info[:ec2_instance_id]
self.info[:ec2_instance_id] = o[:ec2_instance_id]
- `ec2-create-tags #{o[:ec2_instance_id]} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ tag_cmd = ("ec2-create-tags #{o[:ec2_instance_id]} " +
+ "--tag 'Name=#{self.uuid}'")
+ `#{tag_cmd}`
+ end
elsif self.info[:ec2_instance_id] != o[:ec2_instance_id]
logger.debug "Multiple nodes have credentials for #{self.uuid}"
raise "#{self.uuid} is already running at #{self.info[:ec2_instance_id]} so rejecting ping from #{o[:ec2_instance_id]}"
end while true
self.hostname = self.class.hostname_for_slot(self.slot_number)
if info[:ec2_instance_id]
- `ec2-create-tags #{self.info[:ec2_instance_id]} --tag 'hostname=#{self.hostname}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{self.info[:ec2_instance_id]} --tag 'hostname=#{self.hostname}'`
+ end
end
end
result.match(/INSTANCE\s*(i-[0-9a-f]+)/) do |m|
instance_id = m[1]
self.info[:ec2_instance_id] = instance_id
- `ec2-create-tags #{instance_id} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{instance_id} --tag 'Name=#{self.uuid}'`
+ end
end
result.match(/SPOTINSTANCEREQUEST\s*(sir-[0-9a-f]+)/) do |m|
sir_id = m[1]
self.info[:ec2_sir_id] = sir_id
- `ec2-create-tags #{sir_id} --tag 'Name=#{self.uuid}'`
+ if (Rails.configuration.compute_node_ec2_tag_enable rescue true)
+ `ec2-create-tags #{sir_id} --tag 'Name=#{self.uuid}'`
+ end
end
self.save!
end