Skip to content

Commit

Permalink
[QOLSVC-8441] make SSM parameter retrieval more robust
Browse files Browse the repository at this point in the history
- Retry up to 5 times if retrieval fails
- Provide fallback default value when appropriate
  • Loading branch information
ThrawnCA committed Dec 3, 2024
1 parent b9653d9 commit a147b6a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions recipes/ckanweb-deploy-exts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,29 @@
sorted_plugin_names.concat(dependent_plugin_names)
sorted_plugin_names.each do |plugin|

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
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 source_revision.nil? or source_url.nil? then
retries += 1
else
if source_type.nil? then
source_type = 'git'
end
break
end
end

# Install Extension
#

datashades_pip_install_app egg_name do
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
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
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
type source_type
revision source_revision
url source_url
end

# Many extensions use a different name on the plugins line so these need to be managed
Expand Down

0 comments on commit a147b6a

Please sign in to comment.