Skip to content

Commit

Permalink
[QOLSVC-8441] retrieve plugin SSM parameters in batches
Browse files Browse the repository at this point in the history
- This should reduce API calls and be fractionally faster
  • Loading branch information
ThrawnCA committed Dec 3, 2024
1 parent 695856e commit 41b01de
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions recipes/ckanweb-deploy-exts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# Batch nodes only need a limited set of extensions for harvesting
# Ascertain whether or not the instance deploying is a batch node
#
require 'json'

batchnode = node['datashades']['layer'] == 'batch'

account_name = "ckan"
Expand Down Expand Up @@ -148,16 +150,23 @@
sorted_plugin_names.each do |plugin|

retries = 0
while retries < 5
egg_name = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/shortname" --query "Parameter.Value" --output text`.strip
source_type = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/app_source/type" --query "Parameter.Value" --output text`.strip
source_revision = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/app_source/revision" --query "Parameter.Value" --output text`.strip
source_url = `aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/app_source/url" --query "Parameter.Value" --output text`.strip
if egg_name.nil? or egg_name == '' or source_revision.nil? or source_revision == '' or source_url.nil? or source_revision == '' then
retries += 1
else
if source_type.nil? then
source_type = 'git'
egg_name = nil
source_type = 'git'
source_revision = nil
source_url = nil
5.times do
plugin_parameters = `aws ssm get-parameters-by-path --region "#{node['datashades']['region']}" --path "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}" --query "Parameters[].{Name: Name, Value: Value}"`.strip
if not (plugin_parameters.nil? or plugin_parameters == '') then
JSON.parse(plugin_parameters).each do |parameter|
if parameter['Name'].end_with?('/shortname') then
egg_name = parameter['Value']
elsif parameter['Name'].end_with?('/app_source/type') then
source_type = parameter['Value']
elsif parameter['Name'].end_with?('/app_source/revision') then
source_revision = parameter['Value']
elsif parameter['Name'].end_with?('/app_source/url') then
source_url = parameter['Value']
end
end
break
end
Expand Down

0 comments on commit 41b01de

Please sign in to comment.