Skip to content

Commit

Permalink
Merge pull request #368 from DataDog/ara.pulido/7_52
Browse files Browse the repository at this point in the history
Pin 7.52.0/6.52.0 versions and release new buildpack
  • Loading branch information
arapulido committed Apr 1, 2024
2 parents c31d895 + 2489929 commit 6066a27
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.19] - 2024-04-01

### Added
- Datadog Agent pinned versions are now `7.52.0` and `6.52.0`.
- When process monitoring is enabled, the process Agent is embedded in the core Agent (reduces slug size)

## [2.18] - 2024-02-20

### Added
- Datadog Agent pinned versions are now `7.51.0` and `6.51.0`.


## [2.17] - 2023-12-20

### Added
Expand Down
36 changes: 30 additions & 6 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set -o pipefail
# set -x

# Set agent pinned version
DD_AGENT_PINNED_VERSION_6="6.51.0-1"
DD_AGENT_PINNED_VERSION_7="7.51.0-1"
DD_AGENT_PINNED_VERSION_6="6.52.0-1"
DD_AGENT_PINNED_VERSION_7="7.52.0-1"

# Parse and derive params
BUILD_DIR=$1
Expand All @@ -27,22 +27,29 @@ else
CACHED_STACK=$STACK
fi

version_equal_or_newer() {
[ "$1" == "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]
}

# Ensure we store the STACK in the cache for next time.
mkdir -p "$CACHE_DIR/.apt"
echo "$STACK" > "$CACHE_DIR/.apt/STACK"

# If a version hasn't been specified, use the pinned version
if [ -f "$ENV_DIR/DD_AGENT_VERSION" ]; then
DD_AGENT_VERSION=$(cat "$ENV_DIR/DD_AGENT_VERSION")
DD_AGENT_MAJOR_VERSION=$(echo $DD_AGENT_VERSION | cut -d'.' -f1)
else
if [ -f "$ENV_DIR/DD_AGENT_MAJOR_VERSION" ]; then
DD_AGENT_MAJOR_VERSION=$(cat "$ENV_DIR/DD_AGENT_MAJOR_VERSION")
if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then
DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_6"
else
DD_AGENT_MAJOR_VERSION="7"
DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_7"
fi
else
DD_AGENT_MAJOR_VERSION="7"
DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_7"
fi
fi
Expand Down Expand Up @@ -101,9 +108,7 @@ done

# Prior to Agent 6.14 there was only 1 python version
DD_AGENT_BASE_VERSION="6.14"
if [ "$DD_AGENT_VERSION" == "$(echo -e "$DD_AGENT_BASE_VERSION\n$DD_AGENT_VERSION" | sort -V | head -n1)" ]; then
DD_PYTHON_VERSION="2"
else
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
if [ -f "$ENV_DIR/DD_PYTHON_VERSION" ]; then
DD_PYTHON_VERSION=$(cat "$ENV_DIR/DD_PYTHON_VERSION")
if [ "$DD_PYTHON_VERSION" != "2" ] && [ "$DD_PYTHON_VERSION" != "3" ]; then
Expand All @@ -114,11 +119,13 @@ else
else
DD_PYTHON_VERSION="2" # if not specified, we default to Python 2
fi
else
DD_PYTHON_VERSION="2"
fi

# Agent 7 onwards is Python3 only and repo file is different
DD_AGENT_BASE_VERSION="7"
if [ "$DD_AGENT_VERSION" != "$(echo -e "$DD_AGENT_BASE_VERSION\n$DD_AGENT_VERSION" | sort -V | head -n1)" ]; then
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
DD_PYTHON_VERSION="3"
# Modify repo file to point to agent 7
cp "$APT_REPO_FILE_7" "$APT_REPO_FILE"
Expand Down Expand Up @@ -225,16 +232,33 @@ if [ -f "$ENV_DIR/DD_APM_ENABLED" ]; then
fi
fi

if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then
DD_AGENT_BASE_VERSION="6.52.0"
else
DD_AGENT_BASE_VERSION="7.52.0"
fi

# If the process agent hasn't been explicitly enabled, delete the agent
if [ -f "$ENV_DIR/DD_PROCESS_AGENT" ]; then
DD_PROCESS_AGENT=$(cat "$ENV_DIR/DD_PROCESS_AGENT")
if [ "$DD_PROCESS_AGENT" == "false" ]; then
topic "DD_PROCESS_AGENT set to false. Removing the process agent."
rm -rf "$APT_DIR/opt/datadog-agent/embedded/bin/process-agent"
# starting on 7.52.0, there is a binary of core+process agent
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
mv -f "$APT_DIR/opt/datadog-agent/bin/agent/core-agent" "$APT_DIR/opt/datadog-agent/bin/agent/agent"
fi
else
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
rm -rf "$APT_DIR/opt/datadog-agent/bin/agent/core-agent"
fi
fi
else
topic "DD_PROCESS_AGENT not set. Removing the process agent."
rm -rf "$APT_DIR/opt/datadog-agent/embedded/bin/process-agent"
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
mv -f "$APT_DIR/opt/datadog-agent/bin/agent/core-agent" "$APT_DIR/opt/datadog-agent/bin/agent/agent"
fi
fi

# We remove the unneeded version of Python
Expand Down
23 changes: 21 additions & 2 deletions extra/datadog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ sed -i -e"s|^.*additional_checksd:.*$|additional_checksd: $DD_CONF_DIR/checks.d\
# Update the Datadog conf yaml to disable cloud provider metadata
sed -i -e"s|^.*cloud_provider_metadata:.*$|cloud_provider_metadata: []|" "$DATADOG_CONF"

version_equal_or_newer() {
[ "$1" == "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]
}

# Include application's datadog configs
APP_DATADOG_DEFAULT="/app/datadog"
APP_DATADOG="${DD_HEROKU_CONF_FOLDER:=$APP_DATADOG_DEFAULT}"
Expand Down Expand Up @@ -73,7 +77,7 @@ done
# Add tags to the config file
DYNOHOST="$(hostname )"
DYNOTYPE=${DYNO%%.*}
BUILDPACKVERSION="dev"
BUILDPACKVERSION="2.19"
DYNO_TAGS="dyno:$DYNO dynotype:$DYNOTYPE buildpackversion:$BUILDPACKVERSION"

# We want always to have the Dyno ID as a host alias to improve correlation
Expand Down Expand Up @@ -142,6 +146,10 @@ fi
PYTHON_DIR=$(find "$DD_DIR/embedded/lib/" -maxdepth 1 -type d -regex ".*/python[2-3]\.[0-9]+" -printf "%f")
DD_PYTHON_VERSION=$(echo $PYTHON_DIR | sed -n -E 's/^python([2-3])\.[0-9]+/\1/p')

# Get agent versions
DD_AGENT_VERSION=$(agent-wrapper version | cut -d " " -f2)
DD_AGENT_MAJOR_VERSION=$(echo $DD_AGENT_VERSION | cut -d'.' -f1)

if [ "$DD_PYTHON_VERSION" = "3" ]; then
# This is not needed for Agent7 onwards, as it only has one Python version
DD_AGENT_BASE_VERSION="7"
Expand Down Expand Up @@ -349,11 +357,22 @@ else
bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/trace-agent -config $DATADOG_CONF 2>&1 &"
fi

if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then
DD_AGENT_BASE_VERSION="6.52.0"
else
DD_AGENT_BASE_VERSION="7.52.0"
fi
# The Process Agent must be run explicitly
if [ "$DD_PROCESS_AGENT" == "true" ]; then
if [ "$DD_LOG_LEVEL_LOWER" == "debug" ]; then
echo "Starting Datadog Process Agent on $DD_HOSTNAME"
fi
bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/process-agent -config $DATADOG_CONF 2>&1 &"
# Starting on Agent 7.52.0, the process agent is included in the agent binary
if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then
ln -sfn "$DD_BIN_DIR"/agent "$DD_BIN_DIR"/process-agent
bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_BIN_DIR/process-agent -config $DATADOG_CONF 2>&1 &"
else
bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/process-agent -config $DATADOG_CONF 2>&1 &"
fi
fi
fi

0 comments on commit 6066a27

Please sign in to comment.