Skip to content

Commit 6d81ce6

Browse files
authored
Merge pull request #753 from cderici/fix-unit-action-run-status
#753 #### Description This fixes the way we set the status of an action that's ran on a unit. Previously only the `action.output` was being returned and the actual status of the action was being retrieved from the `self.data[]` (as the Action object is a modelEntity), which is not reliable at the moment. This PR changes it to get it directly from the Action object returned by the Juju API when the action completes (with either `completed` or `failed`) status. So it should be completely accurate all the time. Fixes #719 #### QA Steps Following should pass %100. ``` tox -e integration -- tests/integration/test_unit.py::test_run ```
2 parents 0afe0d6 + 83519c6 commit 6d81ce6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

juju/action.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ class Action(model.ModelEntity):
66
def __init__(self, entity_id, model, history_index=-1, connected=True):
77
super().__init__(entity_id, model, history_index, connected)
88
self.results = {}
9+
self._status = self.data['status']
910

1011
@property
1112
def status(self):
12-
return self.data['status']
13+
return self._status
1314

1415
async def fetch_output(self):
15-
self.results = await self.model.get_action_output(self.id)
16+
completed_action = await self.model._get_completed_action(self.id)
17+
self.results = completed_action.output or {}
18+
self._status = completed_action.status
1619

1720
async def wait(self):
1821
self.results or await self.fetch_output()

0 commit comments

Comments
 (0)