Class: UpdateNodeStatusJob

Inherits:
ContainerBrokerBaseJob show all
Defined in:
app/jobs/update_node_status_job.rb

Constant Summary

Constants inherited from ContainerBrokerBaseJob

ContainerBrokerBaseJob::JOB_METRIC

Instance Method Summary collapse

Methods inherited from ContainerBrokerBaseJob

request_id_from_args

Instance Method Details

#perform(node:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/jobs/update_node_status_job.rb', line 6

def perform(node:)
  Rails.logger.debug("Waiting for lock to update status of #{node}")

  updated = LockManager.new(type: self.class.to_s, id: node.id, expire: 1.minute, wait: false).lock do
    Rails.logger.debug("Lock acquired for update status of #{node}")

    node.runner_service(:update_node_status).perform(node: node)

    Rails.logger.debug("Releasing lock for update status of #{node}")
    true
  end

  if updated
    Rails.logger.debug("Lock released for update status of #{node}")
  else
    Rails.logger.debug("Node updating is locked by another job and will be ignored now")
  end
end