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

Fix DD_TAGS export with nodejs buildpack #155

Closed
wants to merge 10 commits into from

Conversation

sarah-witt
Copy link
Contributor

@sarah-witt sarah-witt commented Jan 27, 2023

What does this PR do?

Detects what language buildpack is running by checking staging.yaml then falling back to detecting node specific files if that file is not available.

If the nodejs buildpack is running, then we export DD_TAGS as a comma and space separated list. We need to do this because the nodejs tracer does not support exporting DD_TAGS as spaces.

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@sarah-witt sarah-witt added the changelog/Fixed Fixed features results into a bug fix version bump label Jan 27, 2023
@sarah-witt sarah-witt changed the title Export all tags as comma separated Export all tags with comma delimiters Jan 27, 2023
@sarah-witt sarah-witt marked this pull request as ready for review January 27, 2023 19:54
@sarah-witt sarah-witt requested a review from a team as a code owner January 27, 2023 19:54
@sarah-witt sarah-witt changed the title Export all tags with comma delimiters Determine DD_TAGS format by detecting language buildpack Feb 8, 2023
@sarah-witt sarah-witt changed the title Determine DD_TAGS format by detecting language buildpack Export DD_TAGS by detecting language buildpack Feb 8, 2023
@sarah-witt sarah-witt changed the title Export DD_TAGS by detecting language buildpack Fix DD_TAGS export with nodejs buildpack Feb 8, 2023
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2022-Present Datadog, Inc.
BUILD_DIR="${BUILD_DIR:-/tmp/app}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
BUILD_DIR="${BUILD_DIR:-/tmp/app}"
VCAP_DIR="/home/vcap"

The staging_info.yml file is always extracted to the /home/vcap directory.

See https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#-droplet-filesystem

if [ -n "${LEGACY_TAGS_FORMAT}" ]; then
echo "export LEGACY_TAGS_FORMAT='${LEGACY_TAGS_FORMAT}'" >> "${env_file}"
fi
if [ -n "${DD_DETECTED_BUILDPACK}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Instead of sharing the DD_DETECTED_BUILDPACK var across all the scripts that output tags. I think it would be better to share a DD_TAGS_SEPARATOR var instead, and extract the logic of detecting which format to use outside of the scripts, and in a unique location.

DD_DETECTED_BUILDPACK=""
if [ -f "${BUILD_DIR}"/staging_info.yml ]; then
DD_DETECTED_BUILDPACK=$(cat "${BUILD_DIR}"/staging_info.yml | jq '.detected_buildpack')
elif [ -f "${BUILD_DIR}"/package-lock.json ] || [ -f "${BUILD_DIR}"/yarn.lock ]; then
Copy link
Member

@NouemanKHAL NouemanKHAL Feb 9, 2023

Choose a reason for hiding this comment

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

Suggested change
elif [ -f "${BUILD_DIR}"/package-lock.json ] || [ -f "${BUILD_DIR}"/yarn.lock ]; then
elif [ -f "${BUILD_DIR}"/app/package-lock.json ] || [ -f "${BUILD_DIR}"/app/yarn.lock ]; then

I am not sure if we should go with this approach, but if we do, we'll also have to check for package.json or node_modules.

I would also prefer checking the start_command field in the staging_info.yml.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days.
Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity.

@github-actions github-actions bot added the stale Stale - Bot reminder label Mar 24, 2023
@NouemanKHAL
Copy link
Member

See #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Fixed Fixed features results into a bug fix version bump stale Stale - Bot reminder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants