Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix removing and adding a remote relation #7672
Conversation
| } | ||
| - return ops | ||
| + tokenOps := r.removeRemoteEntityOps(s.SourceModel(), s.Tag(), token) |
axw
Jul 26, 2017
Member
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?
| + return nil, errors.Trace(err) | ||
| + } | ||
| + if err == nil { | ||
| + // Token already exists, so remove first. |
axw
Jul 26, 2017
Member
If it already exists, can't you just return jujutxn.ErrNoOperations? it appears that you're removing and importing the exact same thing?
wallyworld
Jul 26, 2017
Owner
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)...) |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
wallyworld commentedJul 26, 2017
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:
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