Skip to content

fix(agent): Handle nil timer on telegraf reload when no debounce is specified #17373

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

Merged
merged 2 commits into from
Jul 24, 2025

Conversation

neelayu
Copy link
Contributor

@neelayu neelayu commented Jul 22, 2025

Summary

Telegraf was crashing on watch reload. A condition to check if the timer is not nil is added.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #17372

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Jul 22, 2025
@skartikey
Copy link
Contributor

@neelayu Thanks for the PR!

I reviewed the code and see the issue: reloadTimer is only initialized if watchDebounceInterval > 0, but later reloadTimer.Stop() is called unconditionally in both:

  1. case <-ctx.Done():
  2. case <-mytomb.Dying():

If debounce is disabled, reloadTimer is nil, calling .Stop() causes a panic

Suggestion:
Wrap both calls to .Stop() with a nil check:

if reloadTimer != nil {
    reloadTimer.Stop()
}

This ensures safe handling regardless of debounce config or shutdown path.

@skartikey skartikey self-assigned this Jul 23, 2025
@neelayu
Copy link
Contributor Author

neelayu commented Jul 24, 2025

@skartikey
Yes. added the check for the other case as well.

@telegraf-tiger
Copy link
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

☺️ This pull request doesn't significantly change the Telegraf binary size (less than 1%)

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
[[amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip] [arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip] [armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip] [armhf.deb i386.rpm freebsd_armv7.tar.gz ] [i386.deb ppc64le.rpm freebsd_i386.tar.gz ] [mips.deb riscv64.rpm linux_amd64.tar.gz ] [mipsel.deb s390x.rpm linux_arm64.tar.gz ] [ppc64el.deb x86_64.rpm linux_armel.tar.gz ] [riscv64.deb linux_armhf.tar.gz ] [s390x.deb linux_i386.tar.gz ] [ linux_mips.tar.gz ] [ linux_mipsel.tar.gz ] [ linux_ppc64le.tar.gz ] [ linux_riscv64.tar.gz ] [ linux_s390x.tar.gz ]]

Copy link
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@neelayu Thanks!

@skartikey skartikey assigned mstrandboge and unassigned skartikey Jul 24, 2025
@skartikey skartikey added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 24, 2025
@mstrandboge mstrandboge merged commit 5d62207 into influxdata:master Jul 24, 2025
27 checks passed
@github-actions github-actions bot added this to the v1.35.3 milestone Jul 24, 2025
skartikey pushed a commit that referenced this pull request Jul 28, 2025
Mrflatt pushed a commit to elisaedn/telegraf that referenced this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic when telegraf reloads on watch
3 participants