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

feat(agent): Watch for deleted files #15644

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

powersj
Copy link
Contributor

@powersj powersj commented Jul 19, 2024

Summary

Currently, the agent will recognize when config files are deleted and then block the watcher, waiting for them to re-appear. If the file shows back up, the watcher will trigger a reload. This is not likely the intended behavior, instead a user wants to remove a configuration and have telegraf remove that configuration from the running Telegraf.

Note this only works on watched directories. If a user specifies a specific file to load and then deletes it, Telegraf will fail to start as that file is now missing.

In order to avoid any additional error messages on reload, the list of known configs needs to update as well since the file was removed. Therefore, right before the reload we go get a new list of files based on the CLI options + reading any configuration directories.

Checklist

  • No AI generated code was used in this PR

Related issues

Related to #12389
Related to #12264

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jul 19, 2024
@powersj powersj self-assigned this Jul 19, 2024
@powersj powersj 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 19, 2024
@powersj powersj assigned DStrand1 and srebhan and unassigned powersj Jul 19, 2024
@srebhan
Copy link
Member

srebhan commented Jul 22, 2024

@powersj I think we should wait a little bit to see if the files comes back after deletion e.g. if a user moves the file away and then copies a new (or the same) file into the old location. Does that make sense?

Currently, the agent will recognize when config files are deleted and
then block, waiting for them to re-appear. This will trigger a reload.
This is not likely the intended behavior, instead a user wants to remove
a configuration and have telegraf remove that configuration from the
running Telegraf.

Note this only works on watched directories. If a user specifies a
specific file to load and then deletes it, Telegraf will fail to start
as that file is now missing.

In order to avoid any additional error messages on reload, the list of
known configs needs to update as well. Therefore, right before the
reload we go get a new list of files based on the CLI options + reading
any configuration directories.
@telegraf-tiger
Copy link
Contributor

@srebhan srebhan removed their assignment Jul 24, 2024
@DStrand1 DStrand1 merged commit 26df1e7 into influxdata:master Jul 24, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.32.0 milestone Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin 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.

3 participants