-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
@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.
836c7f3
to
5e4ab2f
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
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
Related issues
Related to #12389
Related to #12264