Skip to content

Commit

Permalink
Merge pull request juju#18736 from manadart/dqlite-rename-global-mode…
Browse files Browse the repository at this point in the history
…l-creation

juju#18736

This is another simple renaming in service of relocating agent version concerns to the model database.

`CreateModel` from the bootstrap service is renamed `CreateGlobalModelRecord` to make clear that it is the global record in the controller database.
  • Loading branch information
jujubot authored Jan 29, 2025
2 parents cc58361 + fa4bdfd commit 8c14e07
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion agent/agentbootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (b *AgentBootstrap) Initialize(ctx stdcontext.Context) (_ *state.Controller
CloudRegion: stateParams.ControllerCloudRegion,
Credential: credential.KeyFromTag(cloudCredTag),
}
controllerModelCreateFunc := modelbootstrap.CreateModel(controllerModelUUID, controllerModelArgs)
controllerModelCreateFunc := modelbootstrap.CreateGlobalModelRecord(controllerModelUUID, controllerModelArgs)

controllerModelDefaults := modeldefaultsbootstrap.ModelDefaultsProvider(
stateParams.ControllerInheritedConfig,
Expand Down
2 changes: 1 addition & 1 deletion domain/keyupdater/keyupdater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *keyUpdaterSuite) SetUpTest(c *gc.C) {
testing.CreateInternalSecretBackend(c, s.ControllerTxnRunner())

modelUUID := modeltesting.GenModelUUID(c)
modelFn := modelbootstrap.CreateModel(modelUUID, domainmodel.GlobalModelCreationArgs{
modelFn := modelbootstrap.CreateGlobalModelRecord(modelUUID, domainmodel.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: cloudName,
Credential: credential.Key{
Expand Down
20 changes: 10 additions & 10 deletions domain/model/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func (m modelTypeStateFunc) CloudType(c context.Context, n string) (string, erro
return m(c, n)
}

// CreateModel is responsible for making a new model with all of its associated
// metadata during the bootstrap process.
// If the GlobalModelCreationArgs does not have a credential name set then no cloud
// credential will be associated with the model.
// CreateGlobalModelRecord is responsible for making a new model with all of its
// associated metadata during the bootstrap process.
// If the GlobalModelCreationArgs does not have a credential name set then no
// cloud credential will be associated with the model.
//
// The only supported agent version during bootstrap is that of the current
// controller. This will be the default if no agent version is supplied.
Expand All @@ -48,12 +48,12 @@ func (m modelTypeStateFunc) CloudType(c context.Context, n string) (string, erro
// - [secretbackenderrors.NotFound] When the secret backend for the model
// cannot be found.
//
// CreateModel expects the caller to generate their own model id and pass it to
// this function. In an ideal world we want to have this stopped and make this
// function generate a new id and return the value. This can only be achieved
// once we have the Juju client stop generating id's for controller models in
// the bootstrap process.
func CreateModel(
// CreateGlobalModelRecord expects the caller to generate their own model id and
// pass it to this function. In an ideal world we want to have this stopped and
// make this function generate a new id and return the value. This can only be
// achieved once we have the Juju client stop generating id's for controller
// models in the bootstrap process.
func CreateGlobalModelRecord(
modelID coremodel.UUID,
args model.GlobalModelCreationArgs,
) internaldatabase.BootstrapOpt {
Expand Down
6 changes: 3 additions & 3 deletions domain/model/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type bootstrapSuite struct {
var _ = gc.Suite(&bootstrapSuite{})

func (s *bootstrapSuite) TestUUIDIsRespected(c *gc.C) {
fn := CreateModel(
fn := CreateGlobalModelRecord(
modeltesting.GenModelUUID(c),
model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Expand Down Expand Up @@ -139,7 +139,7 @@ func (s *modelBootstrapSuite) TestCreateReadOnlyModel(c *gc.C) {
}

// Create a model and then create a read-only model from it.
fn := CreateModel(modelUUID, args)
fn := CreateGlobalModelRecord(modelUUID, args)
err := fn(context.Background(), s.ControllerTxnRunner(), s.NoopTxnRunner())
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -179,7 +179,7 @@ func (s *modelBootstrapSuite) TestCreateModelWithDifferingBuildNumber(c *gc.C) {
}

// Create a model and then create a read-only model from it.
fn := CreateModel(modeltesting.GenModelUUID(c), args)
fn := CreateGlobalModelRecord(modeltesting.GenModelUUID(c), args)
err := fn(context.Background(), s.ControllerTxnRunner(), s.ModelTxnRunner())
c.Assert(err, jc.ErrorIsNil)
}
Expand Down
2 changes: 1 addition & 1 deletion domain/modelconfig/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *bootstrapSuite) SetUpTest(c *gc.C) {
testing.CreateInternalSecretBackend(c, s.ControllerTxnRunner())

modelUUID := modeltesting.GenModelUUID(c)
modelFn := modelbootstrap.CreateModel(
modelFn := modelbootstrap.CreateGlobalModelRecord(
modelUUID,
model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Expand Down
2 changes: 1 addition & 1 deletion domain/modelconfig/modelconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *modelConfigSuite) SetUpTest(c *gc.C) {
testing.CreateInternalSecretBackend(c, s.ControllerTxnRunner())

modelUUID := modeltesting.GenModelUUID(c)
modelFn := modelbootstrap.CreateModel(modelUUID, domainmodel.GlobalModelCreationArgs{
modelFn := modelbootstrap.CreateGlobalModelRecord(modelUUID, domainmodel.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: cloudName,
Credential: credential.Key{
Expand Down
4 changes: 2 additions & 2 deletions domain/services/testing/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (s *DomainServicesSuite) SeedModelDatabases(c *gc.C) {
Owner: s.AdminUserUUID,
}

fn := modelbootstrap.CreateModel(s.ControllerModelUUID, controllerArgs)
fn := modelbootstrap.CreateGlobalModelRecord(s.ControllerModelUUID, controllerArgs)
c.Assert(backendbootstrap.CreateDefaultBackends(coremodel.IAAS)(
ctx, s.ControllerTxnRunner(), s.ModelTxnRunner(c, s.ControllerModelUUID.String())), jc.ErrorIsNil)
err = fn(ctx, s.ControllerTxnRunner(), s.NoopTxnRunner())
Expand All @@ -216,7 +216,7 @@ func (s *DomainServicesSuite) SeedModelDatabases(c *gc.C) {
Owner: s.AdminUserUUID,
}

fn = modelbootstrap.CreateModel(s.DefaultModelUUID, modelArgs)
fn = modelbootstrap.CreateGlobalModelRecord(s.DefaultModelUUID, modelArgs)
err = fn(ctx, s.ControllerTxnRunner(), s.NoopTxnRunner())
c.Assert(err, jc.ErrorIsNil)

Expand Down

0 comments on commit 8c14e07

Please sign in to comment.