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

Add reload logic to collector container start script. #4099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dsessler7
Copy link
Contributor

Issue: PGO-2196

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • New feature
  • Bug fix
  • Documentation
  • Testing enhancement
  • Other

What is the current behavior (link to any open issues here)?

The OTel Collector process does not reload when changes are made to its configuration.

What is the new behavior (if this is a feature change)?

  • Breaking change (fix or feature that would cause existing functionality to change)

The OTel Collector process will now be sent a SIGHUP signal to reload its configuration when a change is made to the config directory.

Other Information:

}

var startScript = fmt.Sprintf(`
OTEL_PIDFILE=/tmp/otel.pid
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the otelcontrib process have a name? Or did we want the PID to check if it's running (without recourse to pgrep)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure of the best way to do this. I used some prior art in our codebase as a starting point


exec {fd}<> <(:||:)
while read -r -t 5 -u "${fd}" ||:; do
logrotate -s /tmp/logrotate.status /etc/logrotate.d/logrotate.conf
%s
if [[ "${directory}" -nt "/proc/self/fd/${fd}" ]] && kill -HUP $(head -1 ${OTEL_PIDFILE?});
Copy link
Member

Choose a reason for hiding this comment

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

🤔 What happens if Bash is terminated? Is the entire container torn down, including the collector?

If so, we can keep the collector pid in a variable in memory.

# start
otel ... &
OTEL_PID=$!

# here
kill -HUP ${OTEL_PID}

# below
[[ ! -e /proc/${OTEL_PID} ]]

Comment on lines -157 to +167
logrotate -s /tmp/logrotate.status /etc/logrotate.d/logrotate.conf
%s
Copy link
Member

Choose a reason for hiding this comment

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

🌱 Perhaps this could always be [[ -r /etc/logrotate.d/logrotate.conf ]] && logrotate ... and the choice to rotate or not would be at the mounting of the config.

Copy link
Contributor

@benjaminjb benjaminjb left a comment

Choose a reason for hiding this comment

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

it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants