[JUJU-1058] Close buffered logger upon termination of converged unit agent #14003
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The installation of a buffered logger, used to ship logs to controllers, spawns a Goroutine that is not managed.
This was not a problem when it was created in the
main
method for jujud, because there was only ever one per agent, and an agent restart would cause termination of the Goroutine.When unit agents were converged as runners into the machine agent, this changed. Now, a terminated unit agent leaves these Goroutines behind.
Here we call the logger's
Close
method when the unit worker's dependency engine completes. This closure causes the loop running in the Goroutine to terminate.QA steps
A test for this would involve repeatedly causing machine agents to soft bounce (restarting their worker graphs). Introspection of the agent's Goroutines would indicate that we are not accumulating them over time.
Documentation changes
None.
Bug reference
N/A