canonical / juju-verify

https://launchpad.net/juju-verify
GNU General Public License v3.0
2 stars 7 forks source link

[run_action_on_units] cache usage to prevent re-execution #133

Closed esunar closed 1 year ago

esunar commented 1 year ago

What if we used the cache in the "run_action_on_units" function to prevent the same action from running again with the same parameters on the same unit.

How should it work:

def run_action_on_units(         units: List[Unit],         action: str,         use_cache: bool = True,         **params: Any ) -> Dict[str, Action]:     """Run juju action on specified units.        ....     """     if use_cache:         cache_result = {unit.entity_id: CACHE[unit.entity_id] for unit in units if unit.entity_id in CACHE}

    task_map = {unit.entity_id: unit.run_action(action, **params) for unit
in units if unit.entity_id not in cache_result}


Imported from Launchpad using lp2gh.