Skip to content

Commit

Permalink
Terminate istio sidecar after migrations if it exists
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Travis Patterson <[email protected]>
  • Loading branch information
matt-royal and Travis Patterson committed Nov 24, 2020
1 parent d7a5fe3 commit 56ee90b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ local-worker: bundle exec rake jobs:local
api-worker: bundle exec rake jobs:generic
clock: bundle exec rake clock:start
deployment-updater: bundle exec rake deployment_updater:start
migrate: /bin/bash -c 'bundle exec rake db:connect && bundle exec rake db:setup_database'
migrate: /bin/bash -c 'bundle exec rake db:connect && bundle exec rake db:setup_database && bundle exec rake db:terminate_istio_if_exists'

21 changes: 21 additions & 0 deletions lib/tasks/db.rake
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ namespace :db do
end
end

desc 'Terminate Istio sidecar for migration job (if one exists)'
task :terminate_istio_if_exists do
puts 'Terminating Istio sidecar'

terminate_istio_sidecar_if_exists
end

desc 'Validate Deployments are not missing encryption keys'
task :validate_encryption_keys do
RakeConfig.context = :api
Expand Down Expand Up @@ -302,4 +309,18 @@ namespace :db do
end
end
end

def terminate_istio_sidecar_if_exists
client = HTTPClient.new
response = client.request(:post, 'http://localhost:15000/quitquitquit')

unless response.code == 200
puts "Failed to terminate Istio sidecar. Received response code: #{response.code}"
return
end

puts 'Istio sidecar is now terminated'
rescue => e
puts "Request to Istio sidecar failed. This is expected if your kubernetes cluster does not use Istio. Error: #{e}"
end
end

0 comments on commit 56ee90b

Please sign in to comment.