Skip to content

Commit

Permalink
Merge pull request juju#18108 from SimonRichardson/objectstore-services
Browse files Browse the repository at this point in the history
juju#18108

This introduces 2 concepts:

 1. It provides a subset of services to drive the object store. 
 2. The model object store is now available in the service factory.

Using these two concepts, we can start interning all the object store usages at the API server level into the domain services. The work to do this was pre-seeded by the provider tracker, so applying it to the object store wasn't a huge lift. The only surprising aspect to this, one that I had forgotten was that we required the controller config. This was easy to implement in the end.

We need to understand if the service factory depending on the upgrade database flag/gate is a wise idea. We can easily change it in the future, but originally was left off because the service factory is lazy evaluated.

## Checklist

<!-- If an item is not applicable, use `~strikethrough~`. -->

- [x] Code style: imports ordered, good names, simple structure, etc
- [x] Comments saying why design decisions were made
- [x] Go unit tests, with comments saying what you're testing

## QA steps

Ensure that we can still deploy charms and agents. There shouldn't be any real concerns, as the services still exist and those haven't changed. Just that they come from a different worker.

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


## Links


**Jira card:** [JUJU-6549](https://warthogs.atlassian.net/browse/JUJU-6549)



[JUJU-6549]: https://warthogs.atlassian.net/browse/JUJU-6549?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
jujubot authored Sep 23, 2024
2 parents e0519e5 + 1c24175 commit 9422f01
Show file tree
Hide file tree
Showing 43 changed files with 1,940 additions and 682 deletions.
12 changes: 11 additions & 1 deletion agent/agenttest/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ func AssertManifoldsDependencies(c *gc.C, manifolds dependency.Manifolds, expect
c.Assert(expectedNames.Difference(names), gc.DeepEquals, empty)

for _, n := range manifoldNames.SortedValues() {
c.Check(dependencies[n], jc.SameContents, expected[n], gc.Commentf("mismatched dependencies for worker %q", n))
if !c.Check(dependencies[n], jc.SameContents, expected[n], gc.Commentf("mismatched dependencies for worker %q", n)) {
// Make life easier when attempting to interpret the output.
// We already know the answer, just tell us what to do!
add := set.NewStrings(dependencies[n]...).Difference(set.NewStrings(expected[n]...)).SortedValues()
remove := set.NewStrings(expected[n]...).Difference(set.NewStrings(dependencies[n]...)).SortedValues()
if len(add) == 0 && len(remove) == 0 {
c.Logf(" > changes required for %q:\n - remove duplicate dependencies\n", n)
} else {
c.Logf(" > changes required for %q:\n - add dependencies: %v\n - remove dependencies %v\n", n, add, remove)
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion apiserver/auditconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (s *auditConfigSuite) TestAuditLoggingUsesExcludeMethods(c *gc.C) {
func (s *auditConfigSuite) TestNewServerValidatesConfig(c *gc.C) {
cfg := testing.DefaultServerConfig(c, nil)
cfg.GetAuditConfig = nil
cfg.ServiceFactoryGetter = s.ServiceFactoryGetter(c)
cfg.ServiceFactoryGetter = s.ServiceFactoryGetter(c, s.NoopObjectStore(c))

srv, err := apiserver.NewServer(context.Background(), cfg)
c.Assert(err, gc.ErrorMatches, "missing GetAuditConfig not valid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ func (s *withoutControllerSuite) TestSetInstanceInfo(c *gc.C) {
dummystorage.StorageProviders(),
provider.CommonStorageProviders(),
}
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))

st := s.ControllerModel(c).State()
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(st.ModelUUID())).Storage(registry)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/agent/provisioner/provisioninginfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *withoutControllerSuite) TestProvisioningInfoWithStorage(c *gc.C) {
dummystorage.StorageProviders(),
provider.CommonStorageProviders(),
}
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))

st := s.ControllerModel(c).State()
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(st.ModelUUID())).Storage(registry)
Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *withoutControllerSuite) TestProvisioningInfoRootDiskVolume(c *gc.C) {
dummystorage.StorageProviders(),
provider.CommonStorageProviders(),
}
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))

st := s.ControllerModel(c).State()
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(st.ModelUUID())).Storage(registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *caasProvisionerSuite) SetUpTest(c *gc.C) {
broker, err := stateenvirons.GetNewCAASBrokerFunc(caas.New)(m, serviceFactory.Cloud(), serviceFactory.Credential())
c.Assert(err, jc.ErrorIsNil)
registry := stateenvirons.NewStorageProviderRegistry(broker)
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(s.st.ModelUUID())).Storage(registry)

s.authorizer = &apiservertesting.FakeAuthorizer{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *iaasProvisionerSuite) newApi(c *gc.C, blockDeviceService storageprovisi
c.Assert(err, jc.ErrorIsNil)
registry := stateenvirons.NewStorageProviderRegistry(env)
s.st = s.ControllerModel(c).State()
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(s.st.ModelUUID())).Storage(registry)

s.authorizer = &apiservertesting.FakeAuthorizer{
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/agent/uniter/uniter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (s *uniterSuite) TestLife(c *gc.C) {
c.Assert(relStatus.Status, gc.Equals, status.Joining)

// We need to dual write to dqlite.
sf := s.ServiceFactorySuite.ServiceFactoryGetter(c).FactoryForModel(s.ServiceFactorySuite.ControllerModelUUID)
sf := s.ServiceFactorySuite.ServiceFactoryGetter(c, s.NoopObjectStore(c)).FactoryForModel(s.ServiceFactorySuite.ControllerModelUUID)
applicationService := sf.Application(service.ApplicationServiceParams{
StorageRegistry: storage.NotImplementedProviderRegistry{},
Secrets: service.NotImplementedSecretService{},
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *applicationSuite) makeAPI(c *gc.C) {
Type: model.IAAS,
}
registry := stateenvirons.NewStorageProviderRegistry(env)
serviceFactoryGetter := s.ServiceFactoryGetter(c)
serviceFactoryGetter := s.ServiceFactoryGetter(c, s.NoopObjectStore(c))
storageService := serviceFactoryGetter.FactoryForModel(model.UUID(st.ModelUUID())).Storage(registry)
applicationService := serviceFactory.Application(service.ApplicationServiceParams{
StorageRegistry: registry,
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *controllerSuite) SetUpTest(c *gc.C) {
s.StateSuite.SetUpTest(c)
s.ServiceFactorySuite.ControllerConfig = controllerCfg
s.ServiceFactorySuite.SetUpTest(c)
jujujujutesting.SeedDatabase(c, s.ControllerSuite.TxnRunner(), s.ServiceFactoryGetter(c)(s.ControllerModelUUID), controllerCfg)
jujujujutesting.SeedDatabase(c, s.ControllerSuite.TxnRunner(), s.ServiceFactoryGetter(c, s.NoopObjectStore(c))(s.ControllerModelUUID), controllerCfg)

s.hub = pubsub.NewStructuredHub(nil)

Expand Down
Loading

0 comments on commit 9422f01

Please sign in to comment.