Skip to content

Commit

Permalink
Merge pull request #177 from newrelic/jonathan/host_networking_health…
Browse files Browse the repository at this point in the history
…checks

Search for host networking mode containers by name during stop_containers
  • Loading branch information
intjonathan authored Jan 27, 2017
2 parents 816ec5b + 28a7b3c commit 75591a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/centurion/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Centurion::Deploy
FAILED_CONTAINER_VALIDATION = 100

def stop_containers(target_server, service, timeout = 30)
old_containers = if service.public_ports.nil? || service.public_ports.empty?
old_containers = if service.public_ports.nil? || service.public_ports.empty? || service.network_mode == 'host'
info "Looking for containers with names like #{service.name}"
target_server.find_containers_by_name(service.name)
else
Expand Down
16 changes: 16 additions & 0 deletions spec/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@

test_deploy.stop_containers(server, service)
end

it 'calls stop_container on the right containers in host networking mode' do
service = Centurion::Service.new(:centurion)
service.network_mode = 'host'
service.add_port_bindings(8080, 80)

second_container = container.dup
second_container = container.dup.tap { |c| c['Id'] = c['Id'].sub(/49494/, '55555') }
containers = [ container, second_container ]

expect(server).to receive(:find_containers_by_name).with(:centurion).and_return(containers)
expect(server).to receive(:stop_container).with(container['Id'], 30).once
expect(server).to receive(:stop_container).with(second_container['Id'], 30).once

test_deploy.stop_containers(server, service)
end
end

describe '#wait_for_load_balancer_check_interval' do
Expand Down

0 comments on commit 75591a3

Please sign in to comment.