Class: Runners::Docker::RemoveRunner

Inherits:
Object
  • Object
show all
Defined in:
app/services/runners/docker/remove_runner.rb

Instance Method Summary collapse

Instance Method Details

#perform(node:, runner_id:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/services/runners/docker/remove_runner.rb', line 6

def perform(node:, runner_id:)
  Rails.logger.info("Removing container #{runner_id} from node #{node}")
  container = ::Docker::Container.get(runner_id, { all: true }, CreateConnection.new.perform(node: node))
  container.kill if container.info["State"]["Status"] == "running"
  container.delete
rescue ::Docker::Error::NotFoundError, ::Docker::Error::ConflictError => e
  Rails.logger.info("Container #{runner_id} already removed - #{e.message} (e.class)")
rescue Excon::Error, ::Docker::Error::TimeoutError => e
  node.register_error(e.message)
end