Skip to content

Commit

Permalink
Merge branch '815-offline-config' into main
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hale <bhale@vmware.com>
  • Loading branch information
nebhale committed Jun 29, 2020
2 parents d1155b1 + fde0665 commit 6a797d7
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/java_buildpack/framework/app_dynamics_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,24 @@ def check_if_resource_exists(resource_uri, conf_file)
def override_default_config_if_applicable
return unless @application.environment['APPD_CONF_HTTP_URL']

agent_root = @application.environment['APPD_CONF_HTTP_URL'].chomp('/') + '/java/'
@logger.info { "Downloading override configuration files from #{agent_root}" }
CONFIG_FILES.each do |conf_file|
uri = URI(agent_root + conf_file)

# `download()` uses retries with exponential backoff which is expensive
# for situations like 404 File not Found. Also, `download()` doesn't expose
# an api to disable retries, which makes this check necessary to prevent
# long install times.
next unless check_if_resource_exists(uri, conf_file)

download(false, uri.to_s) do |file|
Dir.glob(@droplet.sandbox + 'ver*') do |target_directory|
FileUtils.cp_r file, target_directory + '/conf/' + conf_file
JavaBuildpack::Util::Cache::InternetAvailability.instance.available(
true, 'The AppDynamics remote configuration download location is always accessible'
) do
agent_root = @application.environment['APPD_CONF_HTTP_URL'].chomp('/') + '/java/'
@logger.info { "Downloading override configuration files from #{agent_root}" }
CONFIG_FILES.each do |conf_file|
uri = URI(agent_root + conf_file)

# `download()` uses retries with exponential backoff which is expensive
# for situations like 404 File not Found. Also, `download()` doesn't expose
# an api to disable retries, which makes this check necessary to prevent
# long install times.
next unless check_if_resource_exists(uri, conf_file)

download(false, uri.to_s) do |file|
Dir.glob(@droplet.sandbox + 'ver*') do |target_directory|
FileUtils.cp_r file, target_directory + '/conf/' + conf_file
end
end
end
end
Expand Down

0 comments on commit 6a797d7

Please sign in to comment.