From 7ecbc1426aba65c57c2c13d90530dac193d511e7 Mon Sep 17 00:00:00 2001 From: NouemanKHAL Date: Wed, 27 May 2026 20:33:46 +0200 Subject: [PATCH] fix(dd-agent): move bpm chmod +x from pre-start to post-start Run the chmod +x on /var/vcap/sys/run/bpm directories as a BOSH post-start hook so it executes after BPM has created the per-job run directories. Previously this ran during pre-start, before any BPM job had started, so newly added BPM jobs were not covered on first boot. Co-Authored-By: Claude Opus 4.7 (1M context) --- jobs/dd-agent/spec | 1 + jobs/dd-agent/templates/bin/post-start | 13 +++++++++++++ src/helpers/ensure_directories.sh | 2 -- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 jobs/dd-agent/templates/bin/post-start diff --git a/jobs/dd-agent/spec b/jobs/dd-agent/spec index d8d1395b..7d4ef697 100644 --- a/jobs/dd-agent/spec +++ b/jobs/dd-agent/spec @@ -11,6 +11,7 @@ templates: config/bpm.yml.erb: config/bpm.yml data/properties.sh.erb: data/properties.sh bin/pre-start: bin/pre-start + bin/post-start: bin/post-start bin/agent_ctl: bin/agent_ctl bin/process_agent_ctl: bin/process_agent_ctl bin/trace_agent_ctl: bin/trace_agent_ctl diff --git a/jobs/dd-agent/templates/bin/post-start b/jobs/dd-agent/templates/bin/post-start new file mode 100644 index 00000000..514b9be8 --- /dev/null +++ b/jobs/dd-agent/templates/bin/post-start @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# 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 2017-Present Datadog, Inc. + +set -e +set -u + +# Add execute flags to any directory inside the bpm run folder, so that the agent can read pidfiles inside. +# This runs as a post-start so that BPM job directories created when starting BPM-managed processes +# (including any future BPM job added to this release) exist by the time we chmod them. +find /var/vcap/sys/run/bpm -type d -print0 | xargs -0 chmod +x || true diff --git a/src/helpers/ensure_directories.sh b/src/helpers/ensure_directories.sh index 0f659ab6..4f1341f4 100644 --- a/src/helpers/ensure_directories.sh +++ b/src/helpers/ensure_directories.sh @@ -13,8 +13,6 @@ mkdir -p "$LOG_DIR" && chmod 775 "$LOG_DIR" && chown -R vcap "$LOG_DIR" mkdir -p "$RUN_DIR" && chmod 775 "$RUN_DIR" && chown -R vcap "$RUN_DIR" mkdir -p "$TMP_DIR" && chmod 775 "$TMP_DIR" && chown -R vcap "$TMP_DIR" mkdir -p "$CONFD_DIR" && chmod 775 "$CONFD_DIR" && chown -R vcap "$CONFD_DIR" -# Add execute flags to any directory inside the bpm run folder, so that the agent can read pidfiles inside -find /var/vcap/sys/run/bpm -type d -print0 | xargs -0 chmod +x || true set +e set +u