Skip to content

Commit

Permalink
Dynatrace bugfix and improve reliability (#384)
Browse files Browse the repository at this point in the history
* If Dynatrace cannot be configured, don't block app start up
* Default unpack method to unzip

Co-authored-by: Xiwen Cheng <[email protected]>
  • Loading branch information
xiwenc and Xiwen Cheng authored Dec 16, 2020
1 parent 866e33d commit a140603
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 20 additions & 7 deletions buildpack/dynatrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ def stage(buildpack_path, build_path):
token=os.environ.get("DT_PAAS_TOKEN"),
)

util.download_and_unpack(
agent_url,
buildpack_path, # DOT_LOCAL_LOCATION,
build_path, # CACHE_DIR,
)
try:
util.download_and_unpack(
agent_url,
buildpack_path, # DOT_LOCAL_LOCATION,
cache_dir=build_path, # CACHE_DIR,
unpack=True,
)
except Exception as e:
logging.warning(
"Dynatrace agent download and unpack failed", exc_info=True
)


def update_config(m2ee, app_name):
Expand All @@ -39,8 +45,15 @@ def update_config(m2ee, app_name):
"Skipping Dynatrace setup, no DT_TENANTTOKEN found in environment"
)
return
logging.info("Adding Dynatrace")
manifest = get_manifest()
logging.info("Enabling Dynatrace")
try:
manifest = get_manifest()
except Exception as e:
logging.warning(
"Failed to parse Dynatrace manifest file", exc_info=True
)
return

# dynamic default
default_env.update({"DT_TENANTTOKEN": manifest.get("tenantToken")})

Expand Down
2 changes: 1 addition & 1 deletion buildpack/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def download_and_unpack(
("mono-", "jdk-", "jre-", "AdoptOpenJDK-")
):
unpack_cmd.extend(("--strip", "1"))
elif file_name.endswith(".zip"):
else:
unpack_cmd = ["unzip", cached_location, "-d", destination]

if unpack_cmd:
Expand Down

0 comments on commit a140603

Please sign in to comment.