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

[JUJU-1058] Close buffered logger upon termination of converged unit agent #14003

Merged
merged 1 commit into from
May 5, 2022

Conversation

manadart
Copy link
Member

@manadart manadart commented May 5, 2022

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

by the deployer worker.

Calling Close() terminates the logger's loop.

This prevents leakage of the Goroutines spawned to run the logger's loop
method.
@manadart manadart added the 2.9 label May 5, 2022
@manadart
Copy link
Member Author

manadart commented May 5, 2022

$$merge$$

@jujubot jujubot merged commit c3682da into juju:2.9 May 5, 2022
@manadart manadart deleted the 2.9-close-unit-loggers branch May 5, 2022 16:20
Copy link
Member

@jameinel jameinel left a comment

Choose a reason for hiding this comment

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

I'm curious if bufferedLogger and the associated goroutines should be taking a tomb/context.Context so that they die rather than just explicit close here. Thoughts?

jujubot added a commit that referenced this pull request May 16, 2022
#14017

Merge from 2.9 to bring forward:
- #14007 from wallyworld/update-golang-deps
- #14013 from hmlanigan/show-controller-panic
- #14012 from hmlanigan/remove-unit-subordinate
- #13998 from turrisxyz/setup-permissions
- #14011 from ycliuhw/update-ck-overlay
- #14010 from tlm/juju-jenkins-tests
- #14004 from tlm/juju-jenkins-tests
- #14003 from manadart/2.9-close-unit-loggers
- #14001 from jack-w-shaw/JUJU-1050_show_unit_life
- #13890 from juju/dependabot/github_actions/actions/upload-artifact-3
- #14000 from wallyworld/use-go1.18
- #13999 from tlm/juju-jenkins-tests
- #13991 from ycliuhw/fix/lp1968643
- #13997 from tlm/cross-compile
- #13931 from arnodel/juju-885-remove-modelaccess-connection-iface-method
- #13992 from jack-w-shaw/JUJU-1034_reduce_over_verbose_logging_network
- #13993 from hmlanigan/fix-intermittent-fail-testenqueuedoperation
- #13990 from wallyworld/handle-azure-quota-errors
- #13989 from benhoyt/start-worker-if-dead
- #13987 from hpidcock/filter-test-packages

Conflicts:
- cmd/juju/controller/showcontroller.go
- go.mod
- go.sum
- provider/azure/environ_test.go
@manadart
Copy link
Member Author

While it would be fairly easy to use a tomb/context in the case addressed here I.e. the unit agent runner, it is messier for the other agent cases where InstallBufferedLogWriter is called in jujud's Main method before Run happens - we would have to thread it though quite a bit of stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants