Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 56ee90b

Browse files
matt-royalTravis Patterson
andcommitted
Terminate istio sidecar after migrations if it exists
Without this change the job never completes because the istio-proxy runs forever. We make a request to the Istio sidecar admin port (15000) to terminate it. If we receive a non-200 response or an exception occurs, we print details and exit 0. [#175367511] Co-authored-by: Matt Royal <mroyal@vmware.com> Co-authored-by: Travis Patterson <travisp@vmware.com>
1 parent d7a5fe3 commit 56ee90b

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ local-worker: bundle exec rake jobs:local
33
api-worker: bundle exec rake jobs:generic
44
clock: bundle exec rake clock:start
55
deployment-updater: bundle exec rake deployment_updater:start
6-
migrate: /bin/bash -c 'bundle exec rake db:connect && bundle exec rake db:setup_database'
6+
migrate: /bin/bash -c 'bundle exec rake db:connect && bundle exec rake db:setup_database && bundle exec rake db:terminate_istio_if_exists'
77

lib/tasks/db.rake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ namespace :db do
165165
end
166166
end
167167

168+
desc 'Terminate Istio sidecar for migration job (if one exists)'
169+
task :terminate_istio_if_exists do
170+
puts 'Terminating Istio sidecar'
171+
172+
terminate_istio_sidecar_if_exists
173+
end
174+
168175
desc 'Validate Deployments are not missing encryption keys'
169176
task :validate_encryption_keys do
170177
RakeConfig.context = :api
@@ -302,4 +309,18 @@ namespace :db do
302309
end
303310
end
304311
end
312+
313+
def terminate_istio_sidecar_if_exists
314+
client = HTTPClient.new
315+
response = client.request(:post, 'http://localhost:15000/quitquitquit')
316+
317+
unless response.code == 200
318+
puts "Failed to terminate Istio sidecar. Received response code: #{response.code}"
319+
return
320+
end
321+
322+
puts 'Istio sidecar is now terminated'
323+
rescue => e
324+
puts "Request to Istio sidecar failed. This is expected if your kubernetes cluster does not use Istio. Error: #{e}"
325+
end
305326
end

0 commit comments

Comments
 (0)