-
Notifications
You must be signed in to change notification settings - Fork 14
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
Wait for agent startup before updating CAPI tags #145
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19b820e
Properly wait for agent startup
sarah-witt c43bce7
Wait for token as well
sarah-witt 6f75187
small refactor
NouemanKHAL a93dc33
Add back datadog dir when using as argument; harmonize compile and su…
sarah-witt 65310a5
Fix pid file name
sarah-witt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/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 2022-Present Datadog, Inc. | ||
|
||
DATADOG_DIR="${DATADOG_DIR:-/home/vcap/app/.datadog}" | ||
|
||
check_datadog() { | ||
while true; do | ||
echo "Waiting for agent or dogstatsd process to start" | ||
if [ -f "${DATADOG_DIR}/run/agent.pid" ]; then | ||
echo "Found agent process" | ||
if [ -f "${DATADOG_DIR}/dist/auth_token" ]; then | ||
echo "Found agent token" | ||
break | ||
else | ||
echo "Agent token not found" | ||
fi | ||
fi | ||
|
||
if [ -f "${DATADOG_DIR}/run/dogstatsd.pid" ]; then | ||
echo "Found dogstatsd process" | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
} | ||
|
||
main() { | ||
check_datadog | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
#!/bin/sh | ||
|
||
# wait for the buildpack scripts to finish | ||
timeout=0 | ||
while { ! [ "$(pgrep -f ./agent)" = "" ] && ! [ "$(pgrep -f ./dogstatsd)" = "" ]; } && [ $timeout -lt 120 ]; do | ||
sleep 1 | ||
timeout=$((timeout+1)) | ||
done | ||
# 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. | ||
|
||
# for debugging purposes | ||
echo $DD_NODE_AGENT_TAGS >> /home/vcap/app/.datadog/dd-node-agent-tags.log | ||
DATADOG_DIR="${DATADOG_DIR:-/home/vcap/app/.datadog}" | ||
DEBUG_FILE="${DATADOG_DIR}/update_agent_config_out.log" | ||
|
||
main() { | ||
# wait for the buildpack scripts to finish | ||
echo "Starting to wait for agent process to start" | ||
timeout 120s "${DATADOG_DIR}/scripts/check_datadog.sh" | ||
|
||
/bin/bash /home/vcap/app/.datadog/scripts/update_agent_config_restart.sh | ||
echo "$DD_NODE_AGENT_TAGS" | ||
|
||
/bin/bash "${DATADOG_DIR}/scripts/update_agent_config_restart.sh" | ||
} | ||
# for debugging purposes | ||
main "$@" >> "$DEBUG_FILE" 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these processes are started using a pid file and it's logically possible for the associated buildpack applications to have a binary with the same name, does use of -F make more sense with pgrep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does make more sense. However, when this script is invoked by the Garden API, the underlying process doesn't have the
DATADOG_DIR
ENV variable, which we would need to find the pid file (e.g.:${DATADOG_DIR}/run/agent.pid
) . @sarah-witt was using this approach as a temporary workaround. We didn't want to assume thatDATADOG_DIR=/home/vcap/app/.datadog
without careful consideration, as we noticed in some parts in the scriptsDATADOG_DIR
could be a user input.We're going to make a separate PR to address this issue and then we'll resume this PR.