Fix removing and adding a remote relation #7672

Merged
merged 1 commit into from Jul 26, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Jul 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:

  • 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

Looks good overall, just a couple of smallish things.

}
- return ops
+ tokenOps := r.removeRemoteEntityOps(s.SourceModel(), s.Tag(), token)
@axw

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?

@wallyworld

wallyworld Jul 26, 2017

Owner

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

state/remoteentities.go
+ return nil, errors.Trace(err)
+ }
+ if err == nil {
+ // Token already exists, so remove first.
@axw

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

wallyworld Jul 26, 2017

Owner

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

axw approved these changes Jul 26, 2017

state/remoteentities.go
+ return nil, jujutxn.ErrNoOperations
+ }
+ // Token already exists, so remove first.
+ ops = append(ops, r.removeRemoteEntityOps(sourceModel, entity, token)...)
@axw

axw Jul 26, 2017

Member

s/token/remoteEntity.Token/ ?

Owner

wallyworld commented Jul 26, 2017

$$merge$$

Contributor

jujubot commented Jul 26, 2017

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

Contributor

jujubot commented Jul 26, 2017

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

Owner

wallyworld commented Jul 26, 2017

$$merge$$

Contributor

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

1 check passed

github-check-merge-juju Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment