Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Actions for charms.reactive #66
Conversation
stub42
added some commits
Nov 6, 2015
This was referenced May 4, 2016
|
Apologies for the long delay on commenting on this. I wasn't sure what direction would be right for handling actions and only just recently took the time to talk it over with @bcsaller. On the one hand, I've found the I was also on the fence about the state-based dispatch of actions. I like the pattern of config and leadership value states, but @bcsaller pointed out that implicitly removed states artificially couples the reactive loop to a hook invocation which breaks down if we want to move the core of reactive out into a separate daemon to improve isolation / separation of concerns and language independence. Additionally, the name of the current action is fundamentally different than config values in that the action is really telling us explicitly which handler to invoke while config and leadership data is just part of the state of the system. So, the upshot of all this is that I am in favor of this approach (with some specific comments that I'll note shortly) and would like to do away with the state portion of juju-solutions/layer-basic#69. |
|
Because of the RPC nature of actions that I mentioned in my previous comment, I think actions should skip the "other" phase entirely, so that only We also need to add the |
|
Running the 'other' phase after the Its worth mentioning that writing actions in this fashion is opt-in. The charmer needs to copy the template to the actions/action-name path (manually, or in the future by declaring it in layer.yaml and having charm build do it). If people want a self contained action that does not trigger reactive states they can continue to do so like they do today. They could even import charms.reactive and alter state of future hooks (we could provide helpers for that). What they can't do is, for example, change the service's administrative password and alter the reactive state causing the existing handlers to kick in and publish the updated password everywhere. And they especially can't do that if the action is defined in a layer and the handlers that need to be invoked defined in a charm using that layer. The state portion in juju-solutions/layer-basic#69 can certainly be done away with, as to my mind it just provides an alternate spelling (and could be implemented in a layer with a |
|
I see your point about the charm potentially needing to react to state changes made by an action. As far as reactive actions being opt-in, my inclination would be to modify |
|
It just occurred to me that one of the goals of integrating actions with reactive is to be able to gate or choose action implementation based on state which would imply that we'd want |
|
It seems we'd want to transition @hook and maybe @action to @event where @event('config.changed') denote that after one pass through of the loop the event is going away? I On Tue, Jun 28, 2016 at 12:22 PM Cory Johns notifications@github.com
|
|
@marcoceppi The trick is ordering, as @johnsca Similarly, I'm not sure why |
|
Is there anything blocking this? The remaining issues I'm aware of of can all go into separate branches, and I see nothing that needs to be in-place before landing this PR:
|
|
Can this please land or be rejected? Its been in limbo for over 6 months, as are the things I need this for. |
arosales
commented
Dec 6, 2016
•
|
@stub42 apologies for the delay in reply here. Chatting with @johnsca we do need to get consensus from @bcsaller and @marcoceppi on the design on actions in the reactive framework. @bcsaller @marcoceppi @johnsca, -thanks, |
|
Specifically, the outstanding questions as I understood them were:
|
|
For the boilerplate, juju-solutions/layer-basic#69 adds an actions/action.template to the base layer. It can land after this PR. charm-tools will need a new feature, so charmer authors can declare actions and have 'charm build' install the template with the correct action name, but that work is not required and can be done after this PR. Per discussions in Pasadena, I think it is critical that reactive actions invoke the rest of the reactive bus. If you don't want this, you should write a traditional action. Adding reactive action support in no way stops you writing traditional, non-reactive actions and I have use cases for both approaches. |
|
Can this please land or be rejected? Its been in limbo for over 6 months, as are the things I need this for. |
arosales
commented
Jan 20, 2017
|
Thanks for your patience and code on this pull. To your point on reactive actions invoking the rest of the reactive bus is the sticking point on the design of the reactive framework. I know there are strong opinions on both sides, and I think this has been the main point of the length of this pull. Also to your point I think this pull is at a point where we should:
I'll confirm with @johnsca and @marcoceppi on Tuesday (Jan 24) on the direction this pull should go and act accordingly. -thanks, |
|
There has been a lot of discussion on how to best model actions in reactive and there seems to be general agreement that actions are fundamentally not reactive, in that they are an explicit, user generated invocation rather than a reaction to an event which represents a change in the state of the system, such as hook. I think that the desired integration with the reactive pattern boils down to three things:
The first isn't relevant to this PR. The second can be done using Therefore, I don't want to move forward with adding new primitives to the framework to support this, and I'm going to close this PR in favor of the discussion in #90. |
stub42 commentedMay 4, 2016
This branch implements #11
It adds a new
@action decorator. When the entry point is an action rather than a hook, the@actionhandlers are invoked instead of the@hookhandlers. Nothing else changes - all the standard 'other' handlers will be invoked.This branch also pulls in my 'preflight' branch from #20 , so you might want to check that out in isolation. This branch also added a new phase to the main dispatcher, and seemed a good starting point and avoids conflicts. I think it will also be needed to fix juju-solutions/layer-basic#68 (if we can be bothered - it is pretty obscure and never seen in the wild).
I will also shortly be proposing pull request to the basic layer, adding an actions.template file to declare the standard entry point. It will also add a standard set of states, allowing you to write your action handlers with standard
@when, and guard handlers that should not run during an action with@when_not. So, assuming you don't need your handler to run before the main handlers, you can declare your action like this: