Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for host networking mode containers by name during stop_containers #177

Merged
merged 1 commit into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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