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

Domain services log context #19000

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

SimonRichardson
Copy link
Member

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing
  • Integration tests, with comments saying what you're testing
  • doc.go added or updated in changed packages

QA steps

Documentation changes

Links

Launchpad bug: https://bugs.launchpad.net/juju/+bug/

Jira card: JUJU-

This is preliminary to rework the logger for the introduction of
writing status history to the model loggers.
The log sink worker is now a logger, we can start removing the
hacky creation of a log worker. It can just be a worker that is
request, much like the domain services.
This verifies that we're actually creating the right model logger
and that they correctly close down when we expect.
In order to create a logger with all the right information, we can
start a model level logger with the correct name.
There is a race to initialise the logger everywhere, so we just
need to create it when it's used.
The model worker manager use to create an ad-hoc logger context
when it started, instead we can prove out this change by wiring that
context directly with the central logger.
We don't need to double write the logsink twice when we start
the model worker manager. The logsink is the logger context. This
means we just need to request that and it has everything already
setup.

This means we can wind out the agent from the modelworkermanager
and just use the id from the agent in the logsink and not in the
modelworkermanager.

We've got the same functionality, but nicely encapsulated inside
of the logsink. Later we'll push the logsink into the domainservices
and all this refactoring will become a lot cleaner.
We no longer need the modelworkermanager recordlogger. It wasn't
even tested!
In order for the logsink worker to be used as a dependency to the
domain services, we have to employ the usual trick of having it's
own set of services that allows the worker to interact with the
database with minimal set of methods. This is the same pattern
we've used with the provider tracker and the objectstore.

The logsink now has less dependencies and we don't need to access the
model in the apiserver everytime an agent requests the logsink
for a model. This is cached at the logsink worker level. It inverts
the dependency...

If in the future we ever want to remove the naming scheme on the
log files, it's easy as it's all encapsulated.
We need to change the domain service interface to accomodate failure
when getting a service. The logger might not be available to we need
to be sure we can actually get it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants