Skip to content

Commit 6a797d7

Browse files
committed
Merge branch '815-offline-config' into main
Signed-off-by: Ben Hale <[email protected]>
2 parents d1155b1 + fde0665 commit 6a797d7

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lib/java_buildpack/framework/app_dynamics_agent.rb

+18-14
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,24 @@ def check_if_resource_exists(resource_uri, conf_file)
171171
def override_default_config_if_applicable
172172
return unless @application.environment['APPD_CONF_HTTP_URL']
173173

174-
agent_root = @application.environment['APPD_CONF_HTTP_URL'].chomp('/') + '/java/'
175-
@logger.info { "Downloading override configuration files from #{agent_root}" }
176-
CONFIG_FILES.each do |conf_file|
177-
uri = URI(agent_root + conf_file)
178-
179-
# `download()` uses retries with exponential backoff which is expensive
180-
# for situations like 404 File not Found. Also, `download()` doesn't expose
181-
# an api to disable retries, which makes this check necessary to prevent
182-
# long install times.
183-
next unless check_if_resource_exists(uri, conf_file)
184-
185-
download(false, uri.to_s) do |file|
186-
Dir.glob(@droplet.sandbox + 'ver*') do |target_directory|
187-
FileUtils.cp_r file, target_directory + '/conf/' + conf_file
174+
JavaBuildpack::Util::Cache::InternetAvailability.instance.available(
175+
true, 'The AppDynamics remote configuration download location is always accessible'
176+
) do
177+
agent_root = @application.environment['APPD_CONF_HTTP_URL'].chomp('/') + '/java/'
178+
@logger.info { "Downloading override configuration files from #{agent_root}" }
179+
CONFIG_FILES.each do |conf_file|
180+
uri = URI(agent_root + conf_file)
181+
182+
# `download()` uses retries with exponential backoff which is expensive
183+
# for situations like 404 File not Found. Also, `download()` doesn't expose
184+
# an api to disable retries, which makes this check necessary to prevent
185+
# long install times.
186+
next unless check_if_resource_exists(uri, conf_file)
187+
188+
download(false, uri.to_s) do |file|
189+
Dir.glob(@droplet.sandbox + 'ver*') do |target_directory|
190+
FileUtils.cp_r file, target_directory + '/conf/' + conf_file
191+
end
188192
end
189193
end
190194
end

0 commit comments

Comments
 (0)