Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix removing and adding a remote relation #7672

Merged
merged 1 commit into from Jul 26, 2017

Conversation

wallyworld
Copy link
Member

Description of change

If a cross model relation is removed and re-added, the relation would not be created again. This PR fixes that and makes other improvements:

  • import remote entity now overwrites any existing token
  • deleting a remote app or relation also now deletes any token
  • relation dying is used to trigger cross model updates, not dead
  • remote relations are always exported using the local model uuid

The last 3 changes will be used in a subsequent PR to clean up remote entity references.

QA steps

Deploy a cmr scenario with mediawiki and mysql
remove relation -> media wiki is blocked
add relation again -> mediawiki is repaired

Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a couple of smallish things.

}
return ops
tokenOps := r.removeRemoteEntityOps(s.SourceModel(), s.Tag(), token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be neater and less error-prone (less unintentional sweeping under the rug) if removeRemoteEntityOps expected a non-empty token, and we only called it here in the case where GetToken above returned a nil error.

I guess it becomes moot if we move the token into the remote application doc though? Is that coming soon?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the next PR will address this so I didn't worry too much here.

return nil, errors.Trace(err)
}
if err == nil {
// Token already exists, so remove first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it already exists, can't you just return jujutxn.ErrNoOperations? it appears that you're removing and importing the exact same thing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being cleaned up next PR, but I've added an improvement here too.

return nil, jujutxn.ErrNoOperations
}
// Token already exists, so remove first.
ops = append(ops, r.removeRemoteEntityOps(sourceModel, entity, token)...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/token/remoteEntity.Token/ ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh!

@wallyworld
Copy link
Member Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jul 26, 2017

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

@jujubot
Copy link
Collaborator

jujubot commented Jul 26, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/58

@wallyworld
Copy link
Member Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jul 26, 2017

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

@jujubot jujubot merged commit 7fe47c9 into juju:develop Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants