DCP: Refactor container
method and usage
This commit is contained in:
@ -78,7 +78,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
|||||||
|
|
||||||
@command = command
|
@command = command
|
||||||
query_params = 'logs=0&stream=1&stderr=1&stdout=1&stdin=1'
|
query_params = 'logs=0&stream=1&stderr=1&stdout=1&stdin=1'
|
||||||
websocket_url = "#{self.class.config[:ws_host]}/v1.27/containers/#{@container_id}/attach/ws?#{query_params}"
|
websocket_url = "#{self.class.config[:ws_host]}/v1.27/containers/#{container.id}/attach/ws?#{query_params}"
|
||||||
|
|
||||||
socket = Connection.new(websocket_url, self, event_loop)
|
socket = Connection.new(websocket_url, self, event_loop)
|
||||||
begin
|
begin
|
||||||
@ -150,12 +150,12 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
|||||||
private
|
private
|
||||||
|
|
||||||
def container
|
def container
|
||||||
return @container if @container.present?
|
@container ||= begin
|
||||||
|
container = Docker::Container.get(@container_id)
|
||||||
|
raise Runner::Error::RunnerNotFound unless container.info['State']['Running']
|
||||||
|
|
||||||
@container = Docker::Container.get(@container_id)
|
container
|
||||||
raise Runner::Error::RunnerNotFound unless @container.info['State']['Running']
|
end
|
||||||
|
|
||||||
@container
|
|
||||||
rescue Docker::Error::NotFoundError
|
rescue Docker::Error::NotFoundError
|
||||||
raise Runner::Error::RunnerNotFound
|
raise Runner::Error::RunnerNotFound
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user