Skip to content

Commit

Permalink
Merge branch '2.8' into dev-merge-2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ycliuhw committed Oct 23, 2020
2 parents 276d08d + 444f84a commit b0452f1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
28 changes: 15 additions & 13 deletions acceptancetests/assess_model_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def ensure_api_login_redirects(source_client, dest_client):
log.info('Attempting migration process')

migrated_model_client = migrate_model_to_controller(
new_model_client, dest_client)
new_model_client, source_client, dest_client)

# check show model controller details
assert_model_has_correct_controller_uuid(migrated_model_client)
Expand Down Expand Up @@ -275,7 +275,7 @@ def ensure_migration_with_resources_succeeds(source_client, dest_client):
test_model, application = deploy_simple_server_to_new_model(
source_client, 'example-model-resource', resource_contents)
migration_target_client = migrate_model_to_controller(
test_model, dest_client)
test_model, source_client, dest_client)
assert_model_migrated_successfully(
migration_target_client, application, resource_contents)

Expand Down Expand Up @@ -307,7 +307,7 @@ def ensure_superuser_can_migrate_other_user_models(
attempt_client.env.user_name)

migration_client = source_client.migrate(
user_qualified_model_name, user_qualified_model_name, dest_client,
user_qualified_model_name, user_qualified_model_name, attempt_client, dest_client,
include_e=False)

wait_for_model(
Expand All @@ -319,34 +319,34 @@ def ensure_superuser_can_migrate_other_user_models(


def migrate_model_to_controller(
source_client, dest_client, include_user_name=False):
source_model, source_client, dest_client, include_user_name=False):
log.info('Initiating migration process')
model_name = get_full_model_name(source_client, include_user_name)
model_name = get_full_model_name(source_model, include_user_name)

migration_target_client = source_client.migrate(
model_name, source_client.env.environment, dest_client,
model_name, source_model.env.environment, source_model, dest_client,
include_e=False,
)

try:
wait_for_model(migration_target_client, source_client.env.environment)
wait_for_model(migration_target_client, source_model.env.environment)
migration_target_client.wait_for_started()
wait_until_model_disappears(
source_client, source_client.env.environment, timeout=480)
source_model, source_model.env.environment, timeout=480)
except JujuAssertionError as e:
# Attempt to show model details as it might log migration failure
# message.
log.error(
'Model failed to migrate. '
'Attempting show-model for affected models.')
try:
source_client.juju('show-model', (model_name), include_e=False)
source_model.juju('show-model', (model_name), include_e=False)
except: # noqa
log.info('Ignoring failed output.')
pass

try:
source_client.juju(
source_model.juju(
'show-model',
get_full_model_name(
migration_target_client, include_user_name),
Expand Down Expand Up @@ -423,7 +423,9 @@ def ensure_model_logs_are_migrated(source_client, dest_client, timeout=600):
before_migration_logs = new_model_client.get_juju_output(
'debug-log', '--no-tail', '-l', 'DEBUG')
log.info('Attempting migration process')
migrated_model = migrate_model_to_controller(new_model_client, dest_client)
migrated_model = migrate_model_to_controller(
new_model_client, source_client, dest_client,
)

assert_logs_appear_in_client_model(
migrated_model, before_migration_logs, timeout)
Expand Down Expand Up @@ -460,7 +462,7 @@ def ensure_migration_rolls_back_on_failure(source_client, dest_client):
test_model, application = deploy_simple_server_to_new_model(
source_client, 'rollmeback')
test_model.migrate(
test_model.env.environment, test_model.env.environment, dest_client,
test_model.env.environment, test_model.env.environment, test_model, dest_client,
include_e=False)
# Once migration has started interrupt it
wait_for_migrating(test_model)
Expand Down Expand Up @@ -534,7 +536,7 @@ def ensure_migrating_with_superuser_user_permissions_succeeds(
user_source_client, 'super-permissions')
log.info('Attempting migration process')
migrated_client = migrate_model_to_controller(
user_new_model, user_dest_client, include_user_name=True)
user_new_model, source_client, user_dest_client, include_user_name=True)
log.info('SUCCESS: superuser migrated other user model.')
migrated_client.destroy_model()

Expand Down
5 changes: 2 additions & 3 deletions acceptancetests/jujupy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,16 +1401,15 @@ def deploy(self, charm, repository=None, to=None, series=None,
# we're deploying a complex set of machines/containers.
return retvar, CommandComplete(WaitAgentsStarted(wait_timeout), ct)

def migrate(self, full_model_name, model_name, dest_client, include_e=True):
def migrate(self, full_model_name, model_name, src_model_client, dest_client, include_e=True):
self.juju(
'migrate',
(full_model_name, dest_client.env.controller.name),
include_e=include_e,
)
# the specified source model has been migrated to the dest client,
# so remove it from self._backend._added_models,
src_model = self.clone(self.env.clone(model_name))
self._backend.untrack_model(src_model)
self._backend.untrack_model(src_model_client)

migration_target_client = dest_client.clone(
dest_client.env.clone(model_name),
Expand Down
10 changes: 8 additions & 2 deletions cloud/fallback-public-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ clouds:
endpoint: https://ec2.eu-north-1.amazonaws.com
eu-south-1:
endpoint: https://ec2.eu-south-1.amazonaws.com
af-south-1:
endpoint: https://ec2.af-south-1.amazonaws.com
ap-east-1:
endpoint: https://ec2.ap-east-1.amazonaws.com
ap-south-1:
Expand All @@ -45,8 +47,6 @@ clouds:
endpoint: https://ec2.me-south-1.amazonaws.com
sa-east-1:
endpoint: https://ec2.sa-east-1.amazonaws.com
af-south-1:
endpoint: https://ec2.af-south-1.amazonaws.com
aws-china:
type: ec2
description: Amazon China
Expand Down Expand Up @@ -80,6 +80,10 @@ clouds:
endpoint: https://www.googleapis.com
us-west2:
endpoint: https://www.googleapis.com
us-west3:
endpoint: https://www.googleapis.com
us-west4:
endpoint: https://www.googleapis.com
asia-east1:
endpoint: https://www.googleapis.com
asia-east2:
Expand All @@ -94,6 +98,8 @@ clouds:
endpoint: https://www.googleapis.com
asia-southeast1:
endpoint: https://www.googleapis.com
asia-southeast2:
endpoint: https://www.googleapis.com
australia-southeast1:
endpoint: https://www.googleapis.com
europe-north1:
Expand Down
10 changes: 8 additions & 2 deletions cloud/fallback_public_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ clouds:
endpoint: https://ec2.eu-north-1.amazonaws.com
eu-south-1:
endpoint: https://ec2.eu-south-1.amazonaws.com
af-south-1:
endpoint: https://ec2.af-south-1.amazonaws.com
ap-east-1:
endpoint: https://ec2.ap-east-1.amazonaws.com
ap-south-1:
Expand All @@ -52,8 +54,6 @@ clouds:
endpoint: https://ec2.me-south-1.amazonaws.com
sa-east-1:
endpoint: https://ec2.sa-east-1.amazonaws.com
af-south-1:
endpoint: https://ec2.af-south-1.amazonaws.com
aws-china:
type: ec2
description: Amazon China
Expand Down Expand Up @@ -87,6 +87,10 @@ clouds:
endpoint: https://www.googleapis.com
us-west2:
endpoint: https://www.googleapis.com
us-west3:
endpoint: https://www.googleapis.com
us-west4:
endpoint: https://www.googleapis.com
asia-east1:
endpoint: https://www.googleapis.com
asia-east2:
Expand All @@ -101,6 +105,8 @@ clouds:
endpoint: https://www.googleapis.com
asia-southeast1:
endpoint: https://www.googleapis.com
asia-southeast2:
endpoint: https://www.googleapis.com
australia-southeast1:
endpoint: https://www.googleapis.com
europe-north1:
Expand Down
6 changes: 2 additions & 4 deletions cmd/juju/commands/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,7 @@ eu-west-3
eu-central-1
eu-north-1
eu-south-1
af-south-1
ap-east-1
ap-south-1
ap-southeast-1
Expand All @@ -2095,17 +2096,14 @@ ap-northeast-2
ap-northeast-3
me-south-1
sa-east-1
af-south-1
`[1:])
}

func (s *BootstrapSuite) TestBootstrapInvalidRegion(c *gc.C) {
resetJujuXDGDataHome(c)
ctx, err := cmdtesting.RunCommand(c, s.newBootstrapCommand(), "aws/eu-west")
c.Assert(err, gc.ErrorMatches, `region "eu-west" for cloud "aws" not valid`)
c.Assert(cmdtesting.Stderr(ctx), gc.Equals, "Available cloud regions are af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, "+
"ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ca-central-1, eu-central-1, eu-north-1, eu-south-1, eu-west-1, "+
"eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-1, us-east-2, us-west-1, us-west-2\n")
c.Assert(cmdtesting.Stderr(ctx), gc.Equals, "Available cloud regions are af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ca-central-1, eu-central-1, eu-north-1, eu-south-1, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-1, us-east-2, us-west-1, us-west-2\n")
c.Assert(cmdtesting.Stdout(ctx), gc.Equals, ``)
}

Expand Down

0 comments on commit b0452f1

Please sign in to comment.