[WIP] Bug fix: only remove states when last remote unit departs. #2

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

tvansteenburgh commented Apr 21, 2017

Fixes #1.

Not tested yet.

@@ -37,12 +37,12 @@ def joined_or_changed(self):
@hook('{provides:kube-control}-relation-{broken,departed}')
@johnsca

johnsca Apr 24, 2017

Owner

The -broken hook completely fails with the current conversation model for interface layers because there is no REMOTE_UNIT and that's not handled well. It also doesn't have a real use in the reactive pattern because you should be removing the states on a per-unit basis anyway and -broken just becomes the state being removed from the last conversation and thus starting to match @when_not again.

TL;DR: interface layers should only ever use -departed and using -broken can cause some strange issues.

- conv = self.conversation()
- conv.remove_state('{relation_name}.connected')
- conv.remove_state('{relation_name}.gpu.available')
+ if not self.conversations():
@johnsca

johnsca Apr 24, 2017

Owner

In an @hook context, there will always be exactly one conversation, for the REMOTE_UNIT of the hook. I think that this interface layer is actually correct (save for the -broken hook issue mentioned in the other comment) and the issue may be in how it's being used in the charm layer.

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