-
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
Close running outputs when reloading #8769
Conversation
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.
🤝 ✅ CLA has been signed. Thank you!
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.
Please set the global agent variable directly from withinrunAgent()
and please also think about a better name for the global variable. How about runningAgent
or something.
I initalize a global variable named "runningAgent". Move closing outputs into the |
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.
This looks very good already. Just one more minor request, please set the agent to a defined state in case of agent.NewAgent()
fails. I know this call cannot fail currently, but it might fail in the future and I don't want to introduce later hard-to-find issues by assuming the above function to return something sensible in case of error.
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.
Looks good to me.
@viperstars can you please add |
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.
Fine with me.
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.
This is not the right approach. The change has to be internal to the agent after the output has finished processing its writes.
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.
much better, thank you!
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.
Fine with me if you remove the extra log-message as @ssoroka requested/suggested.
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.
Sorry for one more request, but can you move the body of stopRunningOutputs()
to the location of the function call. That is dissolve stopRunningOutputs()
and fold into the gatherLoop()
function. It's only a for
loop that survived, wrapping it in a function is not worth it.
I think we should keep it. I add "stopRunningOutputs" based on the existing function "stopServiceInputs". These two functions work in the same way, so the definition and call should be same. |
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.
Agreed. Looks good to me. @ssoroka any comments?
(cherry picked from commit 71757e8)
(cherry picked from commit 71757e8)
closes #8726, closes #8185
As we know, telegraf will reload when getting a SIGHUP signal. If we go deeper into the reload loop, we can see "runAgent" is called without closing running outputs.
This will cause some issues like reload failure and connection leaking.
Send a SIGHUP to the process
We will get the "address already in use" error:
Sent SIGHUP several times.
We can find more than one tcp connection to influxdb server:
I add some code to fix this.
Required for all PRs: