Skip to content

feat: model life worker #19434

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

Merged
merged 6 commits into from
Apr 9, 2025
Merged

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Apr 4, 2025

This removes another slice of the pie in getting the model worker manager off the API server in terms of a dependency. By depending directly on the domain, we alleviate the burden of every request going through the API server, causing additional load on both the API and in turn the database for login requests. We're reducing the surface area of the API server creating a more focused curated API.

We're unable to remove the controller lifeflag controller facade, as the container agent requires access to it. I suspect though, that rather than having such a generic facade, we could make it more specific.

The api-caller dependencies have not quite gone down yet, and that is because of two more workers:

  • migrationflag
  • migrationmaster

Once those have made the transition, we should be free of the api-caller for most of the workers. A bounce of the API server should not cause Juju to go into a death spiral.

QA steps

$ juju bootstrap lxd test
$ juju add-model default
$ juju deploy ubuntu

@jujubot jujubot added the 4.0 label Apr 4, 2025
@SimonRichardson SimonRichardson force-pushed the create-model-life-worker branch from 3bdb2b0 to 05111da Compare April 4, 2025 19:48
@SimonRichardson SimonRichardson changed the title Create model life worker feat: model life worker Apr 4, 2025
@SimonRichardson SimonRichardson marked this pull request as ready for review April 4, 2025 20:16
Adds GetModelLife and WatchModel methods to the model domain. We
want to know when a model is created, changed etc. This will be
used by the new model life watcher.

This will replace the lifeflag worker that depends on the api and
in turn the apiserver.
The model life worker will replace the life flag on the controller.
The controller doesn't want to create many connections to the api
just to get the information that is readily available via the
domain services.
Starts add worker tests to ensure we've got good coverage of
behaviour.
This wires up modellife worker with the controller manifolds.
@SimonRichardson SimonRichardson force-pushed the create-model-life-worker branch from db4b120 to 08d4745 Compare April 7, 2025 12:13
Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

I love this change. Thanks.

@@ -744,8 +744,7 @@ func (s *Service) GetApplicationLife(ctx context.Context, appName string) (corel
if err != nil {
return "", errors.Errorf("getting life for %q: %w", appName, err)
}
result := appLife.Value()
return result, errors.Capture(err)
return appLife.Value()
Copy link
Member

Choose a reason for hiding this comment

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

Nice to keep running capture over these.

@@ -3,7 +3,10 @@

package life

import corelife "github.com/juju/juju/core/life"
import (
corelife "github.com/juju/juju/core/life"
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to converge these one day.

stmt, err := st.Prepare(`
SELECT &dbModelLife.*
FROM model
WHERE uuid = $dbModelLife.uuid;
Copy link
Member

Choose a reason for hiding this comment

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

Little formatting inconsistency.

@SimonRichardson
Copy link
Member Author

/merge

@jujubot jujubot merged commit 3cf62a9 into juju:main Apr 9, 2025
34 of 38 checks passed
@SimonRichardson SimonRichardson deleted the create-model-life-worker branch April 9, 2025 15:45
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.

4 participants