File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ module Centurion::Deploy
7
7
FAILED_CONTAINER_VALIDATION = 100
8
8
9
9
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'
11
11
info "Looking for containers with names like #{ service . name } "
12
12
target_server . find_containers_by_name ( service . name )
13
13
else
Original file line number Diff line number Diff line change 147
147
148
148
test_deploy . stop_containers ( server , service )
149
149
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
150
166
end
151
167
152
168
describe '#wait_for_load_balancer_check_interval' do
You can’t perform that action at this time.
0 commit comments