Skip to content

Commit

Permalink
Merge pull request juju#18720 from manadart/dqlite-rename-model-creat…
Browse files Browse the repository at this point in the history
…ion-arg

juju#18720

This is a non-functional change aimed at disambiguation.

`ModelCreationArgs` is renamed `GlobalModelCreationArgs` to indicate clearly that this is the global model record that ends up the the controller database.

This work is in service of moving agent version from the controller database to the model database.
  • Loading branch information
jujubot authored Jan 28, 2025
2 parents e1ca09d + 132fddd commit 07c439d
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion agent/agentbootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (b *AgentBootstrap) Initialize(ctx stdcontext.Context) (_ *state.Controller
},
)

controllerModelArgs := modeldomain.ModelCreationArgs{
controllerModelArgs := modeldomain.GlobalModelCreationArgs{
AgentVersion: stateParams.AgentVersion,
Name: stateParams.ControllerModelConfig.Name(),
Owner: adminUserUUID,
Expand Down
6 changes: 3 additions & 3 deletions apiserver/facades/client/modelmanager/mocks/service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apiserver/facades/client/modelmanager/modelmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (m *ModelManagerAPI) createModelNew(
// if there was an error. If a failure to rollback occurs, then the endpoint
// should at least be somewhat idempotent.

creationArgs := model.ModelCreationArgs{
creationArgs := model.GlobalModelCreationArgs{
CloudRegion: args.CloudRegion,
Name: args.Name,
}
Expand Down
6 changes: 3 additions & 3 deletions apiserver/facades/client/modelmanager/modelmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (s *modelManagerSuite) expectCreateModel(
).Return(user.User{UUID: ownerUUID}, nil)

// Create model in controller database.
s.modelService.EXPECT().CreateModel(gomock.Any(), domainmodel.ModelCreationArgs{
s.modelService.EXPECT().CreateModel(gomock.Any(), domainmodel.GlobalModelCreationArgs{
Name: modelCreateArgs.Name,
Owner: ownerUUID,
Cloud: expectedCloudName,
Expand Down Expand Up @@ -576,7 +576,7 @@ func (s *modelManagerSuite) TestCreateModelNoDefaultCredentialNonAdmin(c *gc.C)
// //s.accessService.EXPECT().GetUserByName(
// // gomock.Any(), ownerName,
// //).Return(user.User{UUID: ownerUUID}, nil)
// //s.modelService.EXPECT().CreateModel(gomock.Any(), model.ModelCreationArgs{
// //s.modelService.EXPECT().CreateModel(gomock.Any(), model.GlobalModelCreationArgs{
// // Name: "existing-ns",
// // Owner: ownerUUID,
// // Cloud: "k8s-cloud",
Expand Down Expand Up @@ -1111,7 +1111,7 @@ func (s *modelManagerStateSuite) expectCreateModelStateSuite(
).Return(user.User{UUID: ownerUUID}, nil)

// Create model in controller database.
s.modelService.EXPECT().CreateModel(gomock.Any(), domainmodel.ModelCreationArgs{
s.modelService.EXPECT().CreateModel(gomock.Any(), domainmodel.GlobalModelCreationArgs{
Name: modelCreateArgs.Name,
Owner: ownerUUID,
Cloud: "dummy",
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/modelmanager/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type ModelConfigService interface {
// ModelService defines an interface for interacting with the model service.
type ModelService interface {
// CreateModel creates a model returning the resultant model's new id.
CreateModel(context.Context, model.ModelCreationArgs) (coremodel.UUID, func(context.Context) error, error)
CreateModel(context.Context, model.GlobalModelCreationArgs) (coremodel.UUID, func(context.Context) error, error)

// DefaultModelCloudNameAndCredential returns the default cloud name and
// credential that should be used for newly created models that haven't had
Expand Down
2 changes: 1 addition & 1 deletion domain/cloud/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (s *stateSuite) TestCloudIsControllerCloud(c *gc.C) {
context.Background(),
modelUUID,
coremodel.IAAS,
model.ModelCreationArgs{
model.GlobalModelCreationArgs{
Cloud: testCloud.Name,
Name: coremodel.ControllerModelName,
Owner: user.UUID(s.adminUUID.String()),
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.ModelCreationArgs{
modelFn := modelbootstrap.CreateModel(modelUUID, domainmodel.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: cloudName,
Credential: credential.Key{
Expand Down
4 changes: 2 additions & 2 deletions domain/model/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (m modelTypeStateFunc) CloudType(c context.Context, n string) (string, erro

// CreateModel is responsible for making a new model with all of its associated
// metadata during the bootstrap process.
// If the ModelCreationArgs does not have a credential name set then no cloud
// 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
Expand All @@ -55,7 +55,7 @@ func (m modelTypeStateFunc) CloudType(c context.Context, n string) (string, erro
// the bootstrap process.
func CreateModel(
modelID coremodel.UUID,
args model.ModelCreationArgs,
args model.GlobalModelCreationArgs,
) internaldatabase.BootstrapOpt {
return func(ctx context.Context, controller, model database.TxnRunner) error {
if err := args.Validate(); err != nil {
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 @@ -94,7 +94,7 @@ var _ = gc.Suite(&bootstrapSuite{})
func (s *bootstrapSuite) TestUUIDIsRespected(c *gc.C) {
fn := CreateModel(
modeltesting.GenModelUUID(c),
model.ModelCreationArgs{
model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: s.cloudName,
Credential: credential.Key{
Expand Down Expand Up @@ -126,7 +126,7 @@ func (s *modelBootstrapSuite) TestCreateReadOnlyModel(c *gc.C) {
controllerUUID := uuid.MustNewUUID()
modelUUID := modeltesting.GenModelUUID(c)

args := model.ModelCreationArgs{
args := model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: s.cloudName,
Credential: credential.Key{
Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *modelBootstrapSuite) TestCreateModelWithDifferingBuildNumber(c *gc.C) {
v := jujuversion.Current
v.Build++

args := model.ModelCreationArgs{
args := model.GlobalModelCreationArgs{
AgentVersion: v,
Cloud: s.cloudName,
Credential: credential.Key{
Expand Down
2 changes: 1 addition & 1 deletion domain/model/modelmigration/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (i *importOperation) Execute(ctx context.Context, model description.Model)
}

args := domainmodel.ModelImportArgs{
ModelCreationArgs: domainmodel.ModelCreationArgs{
GlobalModelCreationArgs: domainmodel.GlobalModelCreationArgs{
AgentVersion: agentVersion,
Cloud: model.Cloud(),
CloudRegion: model.CloudRegion(),
Expand Down
8 changes: 4 additions & 4 deletions domain/model/modelmigration/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (i *importSuite) TestModelCreate(c *gc.C) {
i.controllerConfigService.EXPECT().ControllerConfig(gomock.Any()).Return(testing.FakeControllerConfig(), nil)

args := model.ModelImportArgs{
ModelCreationArgs: model.ModelCreationArgs{
GlobalModelCreationArgs: model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: "AWS",
CloudRegion: "region1",
Expand Down Expand Up @@ -210,7 +210,7 @@ func (i *importSuite) TestModelCreateRollbacksOnFailure(c *gc.C) {
i.controllerConfigService.EXPECT().ControllerConfig(gomock.Any()).Return(testing.FakeControllerConfig(), nil)

args := model.ModelImportArgs{
ModelCreationArgs: model.ModelCreationArgs{
GlobalModelCreationArgs: model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: "AWS",
CloudRegion: "region1",
Expand Down Expand Up @@ -297,7 +297,7 @@ func (i *importSuite) TestModelCreateRollbacksOnFailureIgnoreNotFoundModel(c *gc
i.controllerConfigService.EXPECT().ControllerConfig(gomock.Any()).Return(testing.FakeControllerConfig(), nil)

args := model.ModelImportArgs{
ModelCreationArgs: model.ModelCreationArgs{
GlobalModelCreationArgs: model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: "AWS",
CloudRegion: "region1",
Expand Down Expand Up @@ -383,7 +383,7 @@ func (i *importSuite) TestModelCreateRollbacksOnFailureIgnoreNotFoundReadOnlyMod
}

args := model.ModelImportArgs{
ModelCreationArgs: model.ModelCreationArgs{
GlobalModelCreationArgs: model.GlobalModelCreationArgs{
AgentVersion: jujuversion.Current,
Cloud: "AWS",
CloudRegion: "region1",
Expand Down
12 changes: 6 additions & 6 deletions domain/model/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type State interface {
ModelTypeState

// Create creates a new model with all of its associated metadata.
Create(context.Context, coremodel.UUID, coremodel.ModelType, model.ModelCreationArgs) error
Create(context.Context, coremodel.UUID, coremodel.ModelType, model.GlobalModelCreationArgs) error

// Activate is responsible for setting a model as fully constructed and
// indicates the final system state for the model is ready for use.
Expand Down Expand Up @@ -205,7 +205,7 @@ func (s *Service) DefaultModelCloudNameAndCredential(

// CreateModel is responsible for creating a new model from start to finish with
// its associated metadata. The function will return the created model's id.
// If the ModelCreationArgs does not have a credential name set then no cloud
// If the GlobalModelCreationArgs does not have a credential name set then no cloud
// credential will be associated with model.
//
// If the caller has not prescribed a specific agent version to use for the
Expand All @@ -229,7 +229,7 @@ func (s *Service) DefaultModelCloudNameAndCredential(
// cannot be found.
func (s *Service) CreateModel(
ctx context.Context,
args model.ModelCreationArgs,
args model.GlobalModelCreationArgs,
) (coremodel.UUID, func(context.Context) error, error) {
if err := args.Validate(); err != nil {
return "", nil, fmt.Errorf(
Expand All @@ -251,7 +251,7 @@ func (s *Service) CreateModel(
// createModel is responsible for creating a new model from start to finish with
// its associated metadata. The function takes the model id to be used as part
// of the creation. This helps serve both new model creation and model
// importing. If the ModelCreationArgs does not have a credential name set then
// importing. If the GlobalModelCreationArgs does not have a credential name set then
// no cloud credential will be associated with model.
//
// If the caller has not prescribed a specific agent version to use for the
Expand All @@ -277,7 +277,7 @@ func (s *Service) CreateModel(
func (s *Service) createModel(
ctx context.Context,
id coremodel.UUID,
args model.ModelCreationArgs,
args model.GlobalModelCreationArgs,
) (func(context.Context) error, error) {
modelType, err := ModelTypeForCloud(ctx, s.st, args.Cloud)
if err != nil {
Expand Down Expand Up @@ -359,7 +359,7 @@ func (s *Service) ImportModel(
)
}

return s.createModel(ctx, args.ID, args.ModelCreationArgs)
return s.createModel(ctx, args.ID, args.GlobalModelCreationArgs)
}

// ControllerModel returns the model used for housing the Juju controller.
Expand Down
Loading

0 comments on commit 07c439d

Please sign in to comment.