func (s *SourcePrecheckSuite) TestControllerAgentVersionError(c *gc.C) { backend := newFakeBackend() backend.controllerBackend.agentVersionErr = errors.New("boom") err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: retrieving model version: boom") }
func (s *SourcePrecheckSuite) TestDyingControllerMachine(c *gc.C) { backend := &fakeBackend{ controllerBackend: newBackendWithDyingMachine(), } err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: machine 0 is dying") }
func (s *SourcePrecheckSuite) TestProvisioningControllerMachine(c *gc.C) { backend := &fakeBackend{ controllerBackend: newBackendWithProvisioningMachine(), } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "controller: machine 0 not running (allocating)") }
func (s *SourcePrecheckSuite) TestNonStartedControllerMachine(c *gc.C) { backend := &fakeBackend{ controllerBackend: newBackendWithDownMachine(), } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "controller: machine 0 agent not functioning at this time (down)") }
func (s *SourcePrecheckSuite) TestDyingApplication(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", life: state.Dying, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "application foo is dying") }
func (s *SourcePrecheckSuite) TestWithPendingMinUnits(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", minunits: 2, units: []migration.PrecheckUnit{&fakeUnit{name: "foo/0"}}, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "application foo is below its minimum units threshold") }
func (s *SourcePrecheckSuite) TestUnitLost(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", units: []migration.PrecheckUnit{ &fakeUnit{name: "foo/0", lost: true}, }, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "unit foo/0 not idle (lost)") }
func (s *SourcePrecheckSuite) TestUnitNotIdle(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", units: []migration.PrecheckUnit{ &fakeUnit{name: "foo/0", agentStatus: status.Failed}, }, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "unit foo/0 not idle (failed)") }
func (s *SourcePrecheckSuite) TestDeadUnit(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", units: []migration.PrecheckUnit{ &fakeUnit{name: "foo/0", life: state.Dead}, }, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "unit foo/0 is dead") }
func (*SourcePrecheckSuite) TestCharmUpgrades(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "spanner", charmURL: "cs:spanner-3", units: []migration.PrecheckUnit{ &fakeUnit{name: "spanner/0", charmURL: "cs:spanner-3"}, &fakeUnit{name: "spanner/1", charmURL: "cs:spanner-2"}, }, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "unit spanner/1 is upgrading") }
func (s *SourcePrecheckSuite) TestUnitVersionsDontMatch(c *gc.C) { backend := &fakeBackend{ apps: []migration.PrecheckApplication{ &fakeApp{ name: "foo", units: []migration.PrecheckUnit{&fakeUnit{name: "foo/0"}}, }, &fakeApp{ name: "bar", units: []migration.PrecheckUnit{ &fakeUnit{name: "bar/0"}, &fakeUnit{name: "bar/1", version: version.MustParseBinary("1.2.4-trusty-ppc64")}, }, }, }, } err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "unit bar/1 tools don't match model (1.2.4 != 1.2.3)") }
func sourcePrecheck(backend migration.PrecheckBackend) error { return migration.SourcePrecheck(backend) }
func (s *SourcePrecheckSuite) TestNonStartedMachine(c *gc.C) { backend := newBackendWithDownMachine() err := migration.SourcePrecheck(backend) c.Assert(err.Error(), gc.Equals, "machine 0 agent not functioning at this time (down)") }
// Prechecks performs pre-migration checks on the model and // (source) controller. func (api *API) Prechecks() error { return migration.SourcePrecheck(api.precheckBackend) }
func (s *SourcePrecheckSuite) TestDownMachineAgent(c *gc.C) { err := migration.SourcePrecheck(newBackendWithDownMachineAgent()) c.Assert(err.Error(), gc.Equals, "machine 1 agent not functioning at this time (down)") }
func (*SourcePrecheckSuite) TestSuccess(c *gc.C) { backend := newHappyBackend() backend.controllerBackend = newHappyBackend() err := migration.SourcePrecheck(backend) c.Assert(err, jc.ErrorIsNil) }
func (*SourcePrecheckSuite) TestCleanupsError(c *gc.C) { backend := newFakeBackend() backend.cleanupErr = errors.New("boom") err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "checking cleanups: boom") }
func (*SourcePrecheckSuite) TestDyingModel(c *gc.C) { backend := newFakeBackend() backend.model.life = state.Dying err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "model is dying") }
func (s *SourcePrecheckSuite) TestIsUpgradingError(c *gc.C) { backend := newFakeBackend() backend.controllerBackend.isUpgradingErr = errors.New("boom") err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: checking for upgrades: boom") }
func (*SourcePrecheckSuite) TestImportingModel(c *gc.C) { backend := newFakeBackend() backend.model.migrationMode = state.MigrationModeImporting err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "model is being imported as part of another migration") }
func (s *SourcePrecheckSuite) TestProvisioningMachine(c *gc.C) { err := migration.SourcePrecheck(newBackendWithProvisioningMachine()) c.Assert(err.Error(), gc.Equals, "machine 0 not running (allocating)") }
func (*SourcePrecheckSuite) TestCleanupsNeeded(c *gc.C) { backend := newFakeBackend() backend.cleanupNeeded = true err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "cleanup needed") }
func (s *SourcePrecheckSuite) TestControllerMachineVersionsDontMatch(c *gc.C) { backend := newFakeBackend() backend.controllerBackend = newBackendWithMismatchingTools() err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: machine . tools don't match model.+") }
func (s *SourcePrecheckSuite) TestIsUpgrading(c *gc.C) { backend := newFakeBackend() backend.controllerBackend.isUpgrading = true err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: upgrade in progress") }
func (s *SourcePrecheckSuite) TestControllerMachineRequiresReboot(c *gc.C) { backend := newFakeBackend() backend.controllerBackend = newBackendWithRebootingMachine() err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "controller: machine 0 is scheduled to reboot") }
targetUserTag, err := names.ParseUserTag(arg.UserTag) if err != nil { result.Results[i].Error = common.ServerError(errors.Annotate(err, "could not modify controller access")) continue } result.Results[i].Error = common.ServerError( ChangeControllerAccess(c.state, c.apiUser, targetUserTag, arg.Action, controllerAccess)) } return result, nil } var runMigrationPrechecks = func(st *state.State, targetInfo coremigration.TargetInfo) error { // Check model and source controller. if err := migration.SourcePrecheck(migration.PrecheckShim(st)); err != nil { return errors.Annotate(err, "source prechecks failed") } // Check target controller. conn, err := api.Open(targetToAPIInfo(targetInfo), migration.ControllerDialOpts()) if err != nil { return errors.Annotate(err, "connect to target controller") } defer conn.Close() modelInfo, err := makeModelInfo(st) if err != nil { return errors.Trace(err) } err = migrationtarget.NewClient(conn).Prechecks(modelInfo) return errors.Annotate(err, "target prechecks failed")
func (s *SourcePrecheckSuite) TestDyingMachine(c *gc.C) { backend := newBackendWithDyingMachine() err := migration.SourcePrecheck(backend) c.Assert(err, gc.ErrorMatches, "machine 0 is dying") }