Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QOLSVC-8441] make SSM parameter retrieval more robust #484

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

ThrawnCA
Copy link
Contributor

@ThrawnCA ThrawnCA commented Dec 3, 2024

  • Retry up to 5 times if retrieval fails
  • Provide fallback default value when appropriate

@ThrawnCA ThrawnCA requested a review from a team December 3, 2024 01:03
- Retry up to 5 times if retrieval fails
- Provide fallback default value when appropriate
@ThrawnCA ThrawnCA force-pushed the QOLSVC-8441-xloader-failed-startup branch from a147b6a to 695856e Compare December 3, 2024 01:22
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we do a single ssm call and then pull apart the parts to their variables instead of lots of little calls.
i.e.

aws ssm get-parameter --region "#{node['datashades']['region']}" --name "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/

this will have shortname, type, url, revision which we can then pull part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, yes. It would be messier since we would need to import the JSON module, use it to parse the get_parameters result into a list, then iterate through that list checking "if Name is 'foo' then assign Value to foo, else if name is 'baz' then assign Value to baz, etc". But it could be done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could try with ruby/json and decrypt the payload. or you could do with get-parameters --names "name1" "name2" "name3" --query "Parameters[*].[Name,Value]"
and split on name.

require 'json'

# Fetch all parameters in a single call
params = JSON.parse(`aws ssm get-parameters-by-path --region "#{node['datashades']['region']}" --path "/config/CKAN/#{node['datashades']['version']}/app/#{node['datashades']['app_id']}/plugin_apps/#{plugin}/app_source/" --query "Parameters[*].[Name,Value]" --output json`.strip)

# Convert the parameters into a hash for easier access
params_hash = params.each_with_object({}) do |(name, value), hash|
  hash[name.split('/').last] = value
end

type = params_hash['type']
revision = params_hash['revision']
url = params_hash['url']

@ThrawnCA ThrawnCA force-pushed the QOLSVC-8441-xloader-failed-startup branch 3 times, most recently from 531bef2 to 41b01de Compare December 3, 2024 02:54
@ThrawnCA ThrawnCA force-pushed the QOLSVC-8441-xloader-failed-startup branch 2 times, most recently from 8067976 to 1a661db Compare December 3, 2024 03:08
- This should reduce API calls and be fractionally faster
@ThrawnCA ThrawnCA force-pushed the QOLSVC-8441-xloader-failed-startup branch from 1a661db to 25aa1bf Compare December 3, 2024 03:18
@ThrawnCA ThrawnCA merged commit 546c10c into develop Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants