Added run_action task #21

Merged
merged 2 commits into from Nov 22, 2016

Conversation

Projects
None yet
3 participants
Owner

johnsca commented Nov 22, 2016

No description provided.

Owner

johnsca commented Nov 22, 2016

This depends on juju/python-libjuju#15 which has been bundled into the wheelhouse.

@@ -34,3 +34,21 @@ tests:
periodic: 5
until: test_traffic.complete
after: deploy
+- name: test run_action
@petevg

petevg Nov 22, 2016

Collaborator

This change breaks test_rules.py. It's a small fix: you just need to change the length assertion from 2 to 3.

tests/rules.1.yaml
+ until: run_action.complete
+ - do:
+ task: matrix.tasks.run_action
+ application: kibana
@petevg

petevg Nov 22, 2016

Collaborator

This test doesn't deploy kibana, leading to a failure.

@johnsca

johnsca Nov 22, 2016

Owner

It does actually deploy it, but it's not blocking properly on the health check. I'll look in to it.

@johnsca

johnsca Nov 22, 2016

Owner

Looks like it's breaking on an issue in libjuju: juju/python-libjuju#17

matrix/tasks/health.py
else:
result = 'healthy'
context.set_state('health.status', result)
rule.log.info("Health check: %s", result)
- return True
+ return result != 'unhealthy'
@bcsaller

bcsaller Nov 22, 2016

Contributor

I think True here is the right answer. Did this plugin exist successfully is the question. The semantics of the return are not about the work the task did, only if it could or could not.

There might be many occasions where the task is functioning properly but the result isn't as expected. For the type of signaling you expect here I think you'd set a state.

matrix/tasks/run_action.py
+ rule.log.info('Running %s on %s', action_name, unit.name)
+ action = await unit.run_action(action_name, **params)
+ await action.wait()
+ return action.status != 'failed'
@bcsaller

bcsaller Nov 22, 2016

Contributor

Same as above.

Collaborator

petevg commented Nov 22, 2016

Both tox and .yaml tests work great for me now. LGTM/+1 (not merging, because I see that @bcsaller has left comments.)

@petevg petevg merged commit 56f67bf into master Nov 22, 2016

@petevg petevg deleted the task-action branch Nov 22, 2016

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