Skip to content

Commit 75591a3

Browse files
authored
Merge pull request #177 from newrelic/jonathan/host_networking_healthchecks
Search for host networking mode containers by name during stop_containers
2 parents 816ec5b + 28a7b3c commit 75591a3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/centurion/deploy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Centurion::Deploy
77
FAILED_CONTAINER_VALIDATION = 100
88

99
def stop_containers(target_server, service, timeout = 30)
10-
old_containers = if service.public_ports.nil? || service.public_ports.empty?
10+
old_containers = if service.public_ports.nil? || service.public_ports.empty? || service.network_mode == 'host'
1111
info "Looking for containers with names like #{service.name}"
1212
target_server.find_containers_by_name(service.name)
1313
else

spec/deploy_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@
147147

148148
test_deploy.stop_containers(server, service)
149149
end
150+
151+
it 'calls stop_container on the right containers in host networking mode' do
152+
service = Centurion::Service.new(:centurion)
153+
service.network_mode = 'host'
154+
service.add_port_bindings(8080, 80)
155+
156+
second_container = container.dup
157+
second_container = container.dup.tap { |c| c['Id'] = c['Id'].sub(/49494/, '55555') }
158+
containers = [ container, second_container ]
159+
160+
expect(server).to receive(:find_containers_by_name).with(:centurion).and_return(containers)
161+
expect(server).to receive(:stop_container).with(container['Id'], 30).once
162+
expect(server).to receive(:stop_container).with(second_container['Id'], 30).once
163+
164+
test_deploy.stop_containers(server, service)
165+
end
150166
end
151167

152168
describe '#wait_for_load_balancer_check_interval' do

0 commit comments

Comments
 (0)