@@ -194,6 +194,10 @@ async def run(self, command, timeout=None):
194194 considered failed
195195 :returns: A :class:`juju.action.Action` instance.
196196
197+ Note that this is very similarly to unit.run_action only enqueues the action.
198+ You will need to call ``action.wait()`` on the resulting `Action` instance
199+ if you wish to block until the action is complete.
200+
197201 """
198202 action = client .ActionFacade .from_connection (self .connection )
199203
@@ -204,15 +208,32 @@ async def run(self, command, timeout=None):
204208 # Convert seconds to nanoseconds
205209 timeout = int (timeout * 1000000000 )
206210
211+ # It's not enough to only check for the old_client on the connection here
212+ # The old client's ActionFacade is updated to version 7, so
213+ # 2.9 track client may be using either ActionFacade v6 or v7 too
214+ old_facade = client .ActionFacade .best_facade_version (self .connection ) <= 6
215+
207216 res = await action .Run (
208217 applications = [],
209218 commands = command ,
210219 machines = [],
211220 timeout = timeout ,
212221 units = [self .name ],
213222 )
214- the_action = res .results [0 ] if self .connection .is_using_old_client else res .actions [0 ]
215- return await self .model .wait_for_action (the_action .action .tag )
223+
224+ action_result = res .results [0 ] if old_facade else res .actions [0 ]
225+ action = action_result .action
226+
227+ action_id = action .tag
228+ if action_id .startswith ("action-" ):
229+ # strip the action- part of "action-<num>" tag
230+ action_id = action_id [7 :]
231+
232+ error = action_result .error
233+ if error :
234+ raise JujuError ("Action error - {} : {}" .format (error .code , error .message ))
235+
236+ return await self .model ._wait_for_new ('action' , action_id )
216237
217238 async def run_action (self , action_name , ** params ):
218239 """Run an action on this unit.
0 commit comments