migrate cloud-credentials #6548

Merged
merged 2 commits into from Nov 14, 2016

Conversation

Projects
None yet
3 participants
Owner

howbazaar commented Nov 8, 2016

Export the cloud credentials as part of the model description. When importing, the credentials
either have to match or not exist on the target.

migrate cloud-credentials
Export the cloud credentials as part of the model description. When importing, the credentials
either have to match or not exist on the target.
Owner

howbazaar commented Nov 8, 2016

QA

juju bootstrap aws source
juju bootstrap aws target
juju change-user-password
juju add-user tim
juju grant time add-model
juju logout
juju register <...>
juju login admin

juju switch source
juju change-user-password
juju add-user tim
juju grant time add-model
juju logout
juju register <...>
juju login tim
juju add-model to-move
juju deploy ubuntu
// this step is needed to work around a bug in migrations
juju grant admin admin to-move

// wait until ubuntu deployed fully

juju logout
juju login admin
JUJU_DEV_FEATURE_FLAGS=migration juju migrate tim/to-move target
watch -c juju status --color
juju switch target
juju logout
juju login tim
juju models
juju switch to-move
juju add-unit ubuntu
// watch it come up
watch -c juju status --color

A couple of minor suggestions and comments, otherwise looks good.

@@ -49,7 +49,7 @@ build: godeps
go build $(PROJECT)/...
check: godeps
- go test -v -test.timeout=1200s $(PROJECT)/... -check.v
+ go test -v -test.timeout=1500s $(PROJECT)/... -check.v
@babbageclunk

babbageclunk Nov 8, 2016

Member

Is this because the tests in general have been taking longer, or just slow on your machine?

@howbazaar

howbazaar Nov 14, 2016

Owner

Some of the QA tests were timing out close to 1200s if the machine was under load. This just gives it a little longer.

core/description/model_test.go
@@ -66,6 +66,30 @@ func (*ModelSerializationSuite) TestUpdateConfig(c *gc.C) {
})
}
+func (*ModelSerializationSuite) TestCloudCredentails(c *gc.C) {
@babbageclunk

babbageclunk Nov 8, 2016

Member

Typo: Credentails

+ if creds := model.CloudCredential(); creds != nil {
+ // Need to add credential or make sure an existing credential
+ // matches.
+ // TODO: there really should be a way to create a cloud credential
@babbageclunk

babbageclunk Nov 8, 2016

Member

This comment confused me - I guess you mean to create the cloud credential ID? Or to create a tag from (cloud, owner, name).

+ if !names.IsValidCloudCredential(credID) {
+ return nil, nil, errors.Errorf("model credentails id not valid: %q", credID)
+ }
+ credTag := names.NewCloudCredentialTag(credID)
@babbageclunk

babbageclunk Nov 8, 2016

Member

Really this should take the three values rather than one. (Although not in this change.)

@howbazaar

howbazaar Nov 14, 2016

Owner

Yes, this is what I meant by the comment. Added some details to the comment.

state/migration_import.go
+ credTag := names.NewCloudCredentialTag(credID)
+
+ existingCreds, err := st.CloudCredential(credTag)
+ if err != nil {
@babbageclunk

babbageclunk Nov 8, 2016

Member

This would be less nesty as

if errors.IsNotFound(err) {
    // new case
} else if err != nil {
    return nil, nil, errors.Trace(err)
} else {
    // existing case
}

Or just check err != nil && !errors.IsNotFound(err) first so the error return's early.

Owner

howbazaar commented Nov 14, 2016

$$merge$$

Contributor

jujubot commented Nov 14, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 220d7db into juju:develop Nov 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment