From 89d208810d082693b623bb224ff9380dc5caefc7 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Tue, 26 Nov 2024 13:49:53 +0100 Subject: [PATCH] fix: remove sources of target_agent_version from controller database Removes reads and writes of target_agent_version from controller databases. In a couple of places, these are sourced as they should be from the model database. In the case of model summaries they are flat removed - this will need to be rethought at a later time. --- cmd/jujud-controller/agent/machine_test.go | 19 ++--- core/model/readonlymodel.go | 7 +- domain/application/service_test.go | 7 +- domain/application/state/application_test.go | 7 +- domain/application/watcher_test.go | 7 +- domain/model/bootstrap/bootstrap_test.go | 21 +++--- domain/model/state/controllerstate.go | 69 ++----------------- domain/model/state/modelstate.go | 10 --- domain/model/state/types.go | 60 +++++----------- domain/model/types.go | 3 - domain/modelconfig/state/state.go | 2 +- domain/modelconfig/state/state_test.go | 4 +- domain/modelconfig/state/types.go | 2 +- .../schema/model/sql/0004-read-only-model.sql | 1 - domain/schema/schema_test.go | 7 +- domain/secret/service_test.go | 7 +- domain/secret/state/state_test.go | 7 +- domain/secret/watcher_test.go | 7 +- domain/services/testing/service.go | 2 +- 19 files changed, 64 insertions(+), 185 deletions(-) diff --git a/cmd/jujud-controller/agent/machine_test.go b/cmd/jujud-controller/agent/machine_test.go index 84a756facd4..12d0cca8f16 100644 --- a/cmd/jujud-controller/agent/machine_test.go +++ b/cmd/jujud-controller/agent/machine_test.go @@ -37,7 +37,6 @@ import ( "github.com/juju/juju/core/network" coreos "github.com/juju/juju/core/os" jujuversion "github.com/juju/juju/core/version" - "github.com/juju/juju/domain" blockdevicestate "github.com/juju/juju/domain/blockdevice/state" "github.com/juju/juju/environs/filestorage" envstorage "github.com/juju/juju/environs/storage" @@ -283,21 +282,13 @@ func (s *MachineSuite) testUpgradeRequest(c *gc.C, agent runner, tag string, cur // setAgentVersion sets the agent version for the controller model in dqlite. func (s *MachineSuite) setAgentVersion(c *gc.C, vers string) { - st := domain.NewStateBase(s.TxnRunnerFactory()) - db, err := st.DB() - c.Assert(err, jc.ErrorIsNil) + db := s.ModelTxnRunner(c, s.ControllerModelUUID()) - q := ` -UPDATE model_agent -SET target_version = $M.target_agent_version -WHERE model_uuid = $M.model_id -` - args := sqlair.M{ - "model_id": s.ControllerModelUUID(), - "target_agent_version": vers, - } + q := "INSERT INTO agent_version (target_version) values ($M.target_version)" + + args := sqlair.M{"target_version": vers} - stmt, err := st.Prepare(q, args) + stmt, err := sqlair.Prepare(q, args) c.Assert(err, jc.ErrorIsNil) err = db.Txn(context.Background(), func(ctx context.Context, tx *sqlair.TX) error { diff --git a/core/model/readonlymodel.go b/core/model/readonlymodel.go index ca1e341e65c..b84b83c852e 100644 --- a/core/model/readonlymodel.go +++ b/core/model/readonlymodel.go @@ -4,22 +4,17 @@ package model import ( - "github.com/juju/version/v2" - "github.com/juju/juju/core/user" "github.com/juju/juju/internal/uuid" ) // ReadOnlyModel represents the state of a read-only model found in the // model database, not the controller database. -// All the fields are are denormalized from the model database. +// All the fields are denormalized from the controller database. type ReadOnlyModel struct { // UUID represents the model UUID. UUID UUID - // AgentVersion reports the current target agent version for the model. - AgentVersion version.Number - // ControllerUUID represents the controller UUID. ControllerUUID uuid.UUID diff --git a/domain/application/service_test.go b/domain/application/service_test.go index cf0d0319b8e..71ff88ef5ff 100644 --- a/domain/application/service_test.go +++ b/domain/application/service_test.go @@ -20,7 +20,6 @@ import ( coresecrets "github.com/juju/juju/core/secrets" corestorage "github.com/juju/juju/core/storage" coreunit "github.com/juju/juju/core/unit" - jujuversion "github.com/juju/juju/core/version" "github.com/juju/juju/domain" "github.com/juju/juju/domain/application" applicationerrors "github.com/juju/juju/domain/application/errors" @@ -71,9 +70,9 @@ func (s *serviceSuite) SetUpTest(c *gc.C) { modelUUID := uuid.MustNewUUID() err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` - INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) - VALUES (?, ?, ?, "test", "iaas", "test-model", "ec2") - `, modelUUID.String(), coretesting.ControllerTag.Id(), jujuversion.Current.String()) + INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) + VALUES (?, ?, "test", "iaas", "test-model", "ec2") + `, modelUUID.String(), coretesting.ControllerTag.Id()) return err }) c.Assert(err, jc.ErrorIsNil) diff --git a/domain/application/state/application_test.go b/domain/application/state/application_test.go index e3e3846d3d6..7242901ebe3 100644 --- a/domain/application/state/application_test.go +++ b/domain/application/state/application_test.go @@ -21,7 +21,6 @@ import ( "github.com/juju/juju/core/secrets" coreunit "github.com/juju/juju/core/unit" unittesting "github.com/juju/juju/core/unit/testing" - jujuversion "github.com/juju/juju/core/version" "github.com/juju/juju/domain" "github.com/juju/juju/domain/application" "github.com/juju/juju/domain/application/charm" @@ -58,9 +57,9 @@ func (s *applicationStateSuite) TestGetModelType(c *gc.C) { modelUUID := uuid.MustNewUUID() err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` - INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) - VALUES (?, ?, ?, "test", "iaas", "test-model", "ec2") - `, modelUUID.String(), coretesting.ControllerTag.Id(), jujuversion.Current.String()) + INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) + VALUES (?, ?, "test", "iaas", "test-model", "ec2") + `, modelUUID.String(), coretesting.ControllerTag.Id()) return err }) c.Assert(err, jc.ErrorIsNil) diff --git a/domain/application/watcher_test.go b/domain/application/watcher_test.go index dee543834df..62cd2b18caf 100644 --- a/domain/application/watcher_test.go +++ b/domain/application/watcher_test.go @@ -17,7 +17,6 @@ import ( corecharm "github.com/juju/juju/core/charm" "github.com/juju/juju/core/database" corestorage "github.com/juju/juju/core/storage" - jujuversion "github.com/juju/juju/core/version" "github.com/juju/juju/core/watcher/watchertest" "github.com/juju/juju/domain" "github.com/juju/juju/domain/application/charm" @@ -45,9 +44,9 @@ func (s *watcherSuite) SetUpTest(c *gc.C) { modelUUID := uuid.MustNewUUID() err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` - INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) - VALUES (?, ?, ?, "test", "iaas", "test-model", "ec2") - `, modelUUID.String(), coretesting.ControllerTag.Id(), jujuversion.Current.String()) + INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) + VALUES (?, ?, "test", "iaas", "test-model", "ec2") + `, modelUUID.String(), coretesting.ControllerTag.Id()) return err }) c.Assert(err, jc.ErrorIsNil) diff --git a/domain/model/bootstrap/bootstrap_test.go b/domain/model/bootstrap/bootstrap_test.go index 246389c6a10..51b3b22ce63 100644 --- a/domain/model/bootstrap/bootstrap_test.go +++ b/domain/model/bootstrap/bootstrap_test.go @@ -185,15 +185,14 @@ func (s *modelBootstrapSuite) TestCreateModelWithDifferingBuildNumber(c *gc.C) { } type dbReadOnlyModel struct { - UUID string `db:"uuid"` - ControllerUUID string `db:"controller_uuid"` - Name string `db:"name"` - Type string `db:"type"` - TargetAgentVersion sql.NullString `db:"target_agent_version"` - Cloud string `db:"cloud"` - CloudType string `db:"cloud_type"` - CloudRegion string `db:"cloud_region"` - CredentialOwner string `db:"credential_owner"` - CredentialName string `db:"credential_name"` - IsControllerModel bool `db:"is_controller_model"` + UUID string `db:"uuid"` + ControllerUUID string `db:"controller_uuid"` + Name string `db:"name"` + Type string `db:"type"` + Cloud string `db:"cloud"` + CloudType string `db:"cloud_type"` + CloudRegion string `db:"cloud_region"` + CredentialOwner string `db:"credential_owner"` + CredentialName string `db:"credential_name"` + IsControllerModel bool `db:"is_controller_model"` } diff --git a/domain/model/state/controllerstate.go b/domain/model/state/controllerstate.go index 005274f5fcb..4a5f772c946 100644 --- a/domain/model/state/controllerstate.go +++ b/domain/model/state/controllerstate.go @@ -160,15 +160,6 @@ func Create( ) } - // Creates a record for the newly created model and register the target - // agent version. - if err := createModelAgent(ctx, preparer, tx, modelID, input.AgentVersion); err != nil { - return fmt.Errorf( - "creating model %q with id %q agent: %w", - input.Name, modelID, err, - ) - } - // Sets the secret backend to be used for the newly created model. if err := setModelSecretBackend(ctx, preparer, tx, modelID, input.SecretBackend); err != nil { return fmt.Errorf( @@ -378,56 +369,6 @@ WHERE uuid = $dbModel.uuid return coreModel, nil } -// createModelAgent is responsible for creating a new model's agent record for -// the given model id. If a model agent record already exists for the given -// model uuid then an error satisfying [modelerrors.AlreadyExists] is returned. -// If no model exists for the provided UUID then a [modelerrors.NotFound] is -// returned. -func createModelAgent( - ctx context.Context, - preparer domain.Preparer, - tx *sqlair.TX, - modelUUID coremodel.UUID, - agentVersion version.Number, -) error { - modelAgent := dbModelAgent{ - UUID: modelUUID.String(), - PreviousVersion: agentVersion.String(), - TargetVersion: agentVersion.String(), - } - stmt, err := preparer.Prepare(` -INSERT INTO model_agent (*) VALUES ($dbModelAgent.*) -`, modelAgent) - if err != nil { - return errors.Annotatef(err, "preparing insert model agent statement") - } - - var outcome sqlair.Outcome - err = tx.Query(ctx, stmt, modelAgent).Get(&outcome) - if jujudb.IsErrConstraintPrimaryKey(err) { - return fmt.Errorf( - "%w for uuid %q while setting model agent version", - modelerrors.AlreadyExists, modelUUID, - ) - } else if jujudb.IsErrConstraintForeignKey(err) { - return fmt.Errorf( - "%w for uuid %q while setting model agent version", - modelerrors.NotFound, - modelUUID, - ) - } else if err != nil { - return fmt.Errorf("creating model %q agent information: %w", modelUUID, err) - } - - if num, err := outcome.Result().RowsAffected(); err != nil { - return errors.Trace(err) - } else if num != 1 { - return fmt.Errorf("creating model agent record, expected 1 row to be inserted got %d", num) - } - - return nil -} - // setModelSecretBackend sets the secret backend for a given model id. If the // secret backend does not exist a [secretbackenderrors.NotFound] error will be // returned. Should the model already have a secret backend set an error @@ -908,7 +849,7 @@ OR uuid IN (SELECT grant_on return nil, errors.Annotatef(err, "preparing select model statement") } - rval := []coremodel.Model{} + var rval []coremodel.Model err = db.Txn(ctx, func(ctx context.Context, tx *sqlair.TX) error { var result []dbModel if err := tx.Query(ctx, modelStmt, uUUID).GetAll(&result); errors.Is(err, sqlair.ErrNoRows) { @@ -918,12 +859,12 @@ OR uuid IN (SELECT grant_on } for _, r := range result { - model, err := r.toCoreModel() + mod, err := r.toCoreModel() if err != nil { return errors.Trace(err) } - rval = append(rval, model) + rval = append(rval, mod) } return nil @@ -1004,7 +945,7 @@ func (s *State) ListModelSummariesForUser(ctx context.Context, userName user.Nam SELECT (p.access_type, m.uuid, m.name, m.cloud_name, m.cloud_region_name, m.model_type, m.cloud_type, m.owner_name, m.cloud_credential_name, m.cloud_credential_cloud_name, m.cloud_credential_owner_name, - m.life, mll.time, m.target_agent_version) AS (&dbModelSummary.*) + m.life, mll.time) AS (&dbModelSummary.*) FROM v_user_auth u JOIN v_permission p ON p.grant_to = u.uuid JOIN v_model m ON m.uuid = p.grant_on @@ -1077,7 +1018,7 @@ func (s *State) ListAllModelSummaries(ctx context.Context) ([]coremodel.ModelSum SELECT (m.uuid, m.name, m.cloud_name, m.cloud_region_name, m.model_type, m.cloud_type, m.owner_name, m.cloud_credential_name, m.cloud_credential_cloud_name, m.cloud_credential_owner_name, - m.life, m.target_agent_version) AS (&dbModelSummary.*) + m.life) AS (&dbModelSummary.*) FROM v_model m `, dbModelSummary{}) if err != nil { diff --git a/domain/model/state/modelstate.go b/domain/model/state/modelstate.go index 90c44b7a698..368cc165262 100644 --- a/domain/model/state/modelstate.go +++ b/domain/model/state/modelstate.go @@ -153,16 +153,6 @@ func (s *ModelState) Model(ctx context.Context) (coremodel.ReadOnlyModel, error) s.logger.Infof("model %s: cloud credential owner name is empty", model.Name) } - var agentVersion string - if m.TargetAgentVersion.Valid { - agentVersion = m.TargetAgentVersion.String - } - - model.AgentVersion, err = version.Parse(agentVersion) - if err != nil { - return coremodel.ReadOnlyModel{}, fmt.Errorf("parsing model agent version %q: %w", agentVersion, err) - } - model.ControllerUUID, err = uuid.UUIDFromString(m.ControllerUUID) if err != nil { return coremodel.ReadOnlyModel{}, fmt.Errorf("parsing controller uuid %q: %w", m.ControllerUUID, err) diff --git a/domain/model/state/types.go b/domain/model/state/types.go index 1deabf6d31a..60db9079359 100644 --- a/domain/model/state/types.go +++ b/domain/model/state/types.go @@ -5,12 +5,9 @@ package state import ( "database/sql" - "fmt" "time" "github.com/juju/errors" - "github.com/juju/version/v2" - "github.com/juju/juju/core/credential" corelife "github.com/juju/juju/core/life" coremodel "github.com/juju/juju/core/model" @@ -35,9 +32,6 @@ type dbModel struct { // ModelType is the type of model. ModelType string `db:"model_type"` - // AgentVersion is the target version for agents running under this model. - AgentVersion string `db:"target_agent_version"` - // CloudName is the name of the cloud to associate with the model. CloudName string `db:"cloud_name"` @@ -64,10 +58,6 @@ type dbModel struct { } func (m *dbModel) toCoreModel() (coremodel.Model, error) { - agentVersion, err := version.Parse(m.AgentVersion) - if err != nil { - return coremodel.Model{}, fmt.Errorf("parsing model %q agent version %q: %w", m.UUID, agentVersion, err) - } ownerName, err := user.NewName(m.OwnerName) if err != nil { return coremodel.Model{}, errors.Trace(err) @@ -96,14 +86,13 @@ func (m *dbModel) toCoreModel() (coremodel.Model, error) { } return coremodel.Model{ - Name: m.Name, - Life: corelife.Value(m.Life), - UUID: coremodel.UUID(m.UUID), - ModelType: coremodel.ModelType(m.ModelType), - AgentVersion: agentVersion, - Cloud: m.CloudName, - CloudType: m.CloudType, - CloudRegion: cloudRegion, + Name: m.Name, + Life: corelife.Value(m.Life), + UUID: coremodel.UUID(m.UUID), + ModelType: coremodel.ModelType(m.ModelType), + Cloud: m.CloudName, + CloudType: m.CloudType, + CloudRegion: cloudRegion, Credential: credential.Key{ Name: credentialName, Cloud: credentialCloudName, @@ -195,9 +184,6 @@ type dbModelSummary struct { Access permission.Access `db:"access_type"` // UserLastConnection is the last time this user has accessed this model UserLastConnection *time.Time `db:"time"` - - // AgentVersion is the agent version for this model. - AgentVersion string `db:"target_agent_version"` } // decodeModelSummary transforms a dbModelSummary into a coremodel.ModelSummary. @@ -215,16 +201,6 @@ func (m dbModelSummary) decodeUserModelSummary(controllerInfo dbController) (cor // decodeModelSummary transforms a dbModelSummary into a coremodel.ModelSummary. func (m dbModelSummary) decodeModelSummary(controllerInfo dbController) (coremodel.ModelSummary, error) { - var agentVersion version.Number - if m.AgentVersion != "" { - var err error - agentVersion, err = version.Parse(m.AgentVersion) - if err != nil { - return coremodel.ModelSummary{}, errors.Annotatef( - err, "parsing model %q agent version %q", m.Name, agentVersion, - ) - } - } ownerName, err := user.NewName(m.OwnerName) if err != nil { return coremodel.ModelSummary{}, errors.Trace(err) @@ -252,7 +228,6 @@ func (m dbModelSummary) decodeModelSummary(controllerInfo dbController) (coremod IsController: m.UUID == controllerInfo.ModelUUID, OwnerName: ownerName, Life: corelife.Value(m.Life), - AgentVersion: agentVersion, }, nil } @@ -304,17 +279,16 @@ func (info *dbModelUserInfo) toModelUserInfo() (coremodel.ModelUserInfo, error) } type dbReadOnlyModel struct { - UUID string `db:"uuid"` - ControllerUUID string `db:"controller_uuid"` - Name string `db:"name"` - Type string `db:"type"` - TargetAgentVersion sql.NullString `db:"target_agent_version"` - Cloud string `db:"cloud"` - CloudType string `db:"cloud_type"` - CloudRegion string `db:"cloud_region"` - CredentialOwner string `db:"credential_owner"` - CredentialName string `db:"credential_name"` - IsControllerModel bool `db:"is_controller_model"` + UUID string `db:"uuid"` + ControllerUUID string `db:"controller_uuid"` + Name string `db:"name"` + Type string `db:"type"` + Cloud string `db:"cloud"` + CloudType string `db:"cloud_type"` + CloudRegion string `db:"cloud_region"` + CredentialOwner string `db:"credential_owner"` + CredentialName string `db:"credential_name"` + IsControllerModel bool `db:"is_controller_model"` } type dbCloudType struct { diff --git a/domain/model/types.go b/domain/model/types.go index a3860b5ad96..5e41b5747c5 100644 --- a/domain/model/types.go +++ b/domain/model/types.go @@ -105,9 +105,6 @@ type ReadOnlyModelCreationArgs struct { // this value when you are trying to import a model during model migration. UUID coremodel.UUID - // AgentVersion represents the current target agent version for the model. - AgentVersion version.Number - // ControllerUUID represents the unique id for the controller that the model // is associated with. ControllerUUID uuid.UUID diff --git a/domain/modelconfig/state/state.go b/domain/modelconfig/state/state.go index 1b6535eade6..50de70128e5 100644 --- a/domain/modelconfig/state/state.go +++ b/domain/modelconfig/state/state.go @@ -35,7 +35,7 @@ func (st *State) AgentVersion(ctx context.Context) (string, error) { return "", errors.Trace(err) } - q := `SELECT &dbAgentVersion.target_agent_version FROM model` + q := `SELECT &dbAgentVersion.target_version FROM agent_version` rval := dbAgentVersion{} diff --git a/domain/modelconfig/state/state_test.go b/domain/modelconfig/state/state_test.go index 363278ad6de..065055e1272 100644 --- a/domain/modelconfig/state/state_test.go +++ b/domain/modelconfig/state/state_test.go @@ -156,8 +156,8 @@ func (s *stateSuite) TestAgentVersionNotFound(c *gc.C) { func (s *stateSuite) TestAgentVersion(c *gc.C) { err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` - INSERT INTO model (uuid, controller_uuid, name, type, target_agent_version, cloud, cloud_type) - VALUES ("123", "123", "test", "caas", "1.2.3", "kubernetes", "kubernetes") + INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) + VALUES ("123", "123", "test", "caas", "kubernetes", "kubernetes") `) return err }) diff --git a/domain/modelconfig/state/types.go b/domain/modelconfig/state/types.go index 5705ac739c8..806aea225f5 100644 --- a/domain/modelconfig/state/types.go +++ b/domain/modelconfig/state/types.go @@ -12,7 +12,7 @@ type dbKey struct { // dbAgentVersion represents the target agent version from the model table. type dbAgentVersion struct { - TargetAgentVersion string `db:"target_agent_version"` + TargetAgentVersion string `db:"target_version"` } // dbKeyValue represents a key-value pair from the model_config table. diff --git a/domain/schema/model/sql/0004-read-only-model.sql b/domain/schema/model/sql/0004-read-only-model.sql index 48c40ac6459..61f5694beb5 100644 --- a/domain/schema/model/sql/0004-read-only-model.sql +++ b/domain/schema/model/sql/0004-read-only-model.sql @@ -10,7 +10,6 @@ CREATE TABLE model ( controller_uuid TEXT NOT NULL, name TEXT NOT NULL, type TEXT NOT NULL, - target_agent_version TEXT NOT NULL, cloud TEXT NOT NULL, cloud_type TEXT NOT NULL, cloud_region TEXT, diff --git a/domain/schema/schema_test.go b/domain/schema/schema_test.go index 448363c45d3..e6af2a8a2dc 100644 --- a/domain/schema/schema_test.go +++ b/domain/schema/schema_test.go @@ -17,7 +17,6 @@ import ( "github.com/juju/juju/core/database/schema" coresecrets "github.com/juju/juju/core/secrets" - jujuversion "github.com/juju/juju/core/version" databasetesting "github.com/juju/juju/internal/database/testing" ) @@ -934,9 +933,9 @@ func (s *schemaSuite) TestModelTriggersForImmutableTables(c *gc.C) { modelUUID := utils.MustNewUUID().String() controllerUUID := utils.MustNewUUID().String() s.assertExecSQL(c, ` -INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type, cloud_region) -VALUES (?, ?, ?, 'my-model', 'caas', 'cloud-1', 'kubernetes', 'cloud-region-1');`, - modelUUID, controllerUUID, jujuversion.Current.String()) +INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type, cloud_region) +VALUES (?, ?, 'my-model', 'caas', 'cloud-1', 'kubernetes', 'cloud-region-1');`, + modelUUID, controllerUUID) s.assertExecSQLError(c, "UPDATE model SET name = 'new-name' WHERE uuid = ?", "model table is immutable", modelUUID) diff --git a/domain/secret/service_test.go b/domain/secret/service_test.go index c6dd6b06c02..169861dda07 100644 --- a/domain/secret/service_test.go +++ b/domain/secret/service_test.go @@ -17,7 +17,6 @@ import ( coremodel "github.com/juju/juju/core/model" coresecrets "github.com/juju/juju/core/secrets" corestorage "github.com/juju/juju/core/storage" - jujuversion "github.com/juju/juju/core/version" "github.com/juju/juju/domain" applicationservice "github.com/juju/juju/domain/application/service" applicationstate "github.com/juju/juju/domain/application/state" @@ -52,9 +51,9 @@ func (s *serviceSuite) SetUpTest(c *gc.C) { s.modelUUID = modeltesting.CreateTestModel(c, s.TxnRunnerFactory(), "test-model") err := s.ModelTxnRunner(c, s.modelUUID.String()).StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` - INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) - VALUES (?, ?, ?, "test", "iaas", "test-model", "ec2") - `, s.modelUUID, coretesting.ControllerTag.Id(), jujuversion.Current.String()) + INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) + VALUES (?, ?, "test", "iaas", "test-model", "ec2") + `, s.modelUUID, coretesting.ControllerTag.Id()) return err }) s.backendConfigGetter = func(context.Context) (*provider.ModelBackendConfigInfo, error) { diff --git a/domain/secret/state/state_test.go b/domain/secret/state/state_test.go index 7e68011d907..f0a7c589eef 100644 --- a/domain/secret/state/state_test.go +++ b/domain/secret/state/state_test.go @@ -15,7 +15,6 @@ import ( coredatabase "github.com/juju/juju/core/database" coresecrets "github.com/juju/juju/core/secrets" - jujuversion "github.com/juju/juju/core/version" "github.com/juju/juju/domain" applicationerrors "github.com/juju/juju/domain/application/errors" "github.com/juju/juju/domain/life" @@ -51,9 +50,9 @@ func (s *stateSuite) setupModel(c *gc.C) string { modelUUID := uuid.MustNewUUID() err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` -INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) -VALUES (?, ?, ?, "test", "iaas", "fluffy", "ec2") - `, modelUUID.String(), coretesting.ControllerTag.Id(), jujuversion.Current.String()) +INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) +VALUES (?, ?, "test", "iaas", "fluffy", "ec2") + `, modelUUID.String(), coretesting.ControllerTag.Id()) return err }) c.Assert(err, jc.ErrorIsNil) diff --git a/domain/secret/watcher_test.go b/domain/secret/watcher_test.go index 3ee64e98df3..d3bb6876f48 100644 --- a/domain/secret/watcher_test.go +++ b/domain/secret/watcher_test.go @@ -19,7 +19,6 @@ import ( coresecrets "github.com/juju/juju/core/secrets" corestorage "github.com/juju/juju/core/storage" "github.com/juju/juju/core/unit" - jujuversion "github.com/juju/juju/core/version" corewatcher "github.com/juju/juju/core/watcher" "github.com/juju/juju/core/watcher/watchertest" "github.com/juju/juju/domain" @@ -47,9 +46,9 @@ func (s *watcherSuite) SetUpTest(c *gc.C) { err := s.TxnRunner().StdTxn(context.Background(), func(ctx context.Context, tx *sql.Tx) error { _, err := tx.ExecContext(ctx, ` -INSERT INTO model (uuid, controller_uuid, target_agent_version, name, type, cloud, cloud_type) -VALUES (?, ?, ?, "test", "iaas", "fluffy", "ec2") - `, s.ModelUUID(), coretesting.ControllerTag.Id(), jujuversion.Current.String()) +INSERT INTO model (uuid, controller_uuid, name, type, cloud, cloud_type) +VALUES (?, ?, "test", "iaas", "fluffy", "ec2") + `, s.ModelUUID(), coretesting.ControllerTag.Id()) return err }) c.Assert(err, jc.ErrorIsNil) diff --git a/domain/services/testing/service.go b/domain/services/testing/service.go index 68aa4bd73a4..84a5a7c9e92 100644 --- a/domain/services/testing/service.go +++ b/domain/services/testing/service.go @@ -168,7 +168,7 @@ func (s *TestingDomainServices) Secret(secretservice.SecretServiceParams) *secre } // Agent returns the modelagent service. -func (s *TestingDomainServices) Agent() *modelagentservice.ModelService { +func (s *TestingDomainServices) Agent() *modelagentservice.Service { return nil }