From bd8487b3b935ea96805fabdbaa984beb84b9b9bb Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 18 Nov 2015 13:01:56 -0700 Subject: [PATCH] Properly save minion list in local_cache for ssh jobs --- salt/client/ssh/__init__.py | 5 ++++- salt/returners/local_cache.py | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py index 6788fa229e..fb69c9ca65 100644 --- a/salt/client/ssh/__init__.py +++ b/salt/client/ssh/__init__.py @@ -520,7 +520,10 @@ class SSH(object): # save load to the master job cache try: - self.returners['{0}.save_load'.format(self.opts['master_job_cache'])](jid, job_load) + if self.opts['master_job_cache'] == 'local_cache': + self.returners['{0}.save_load'.format(self.opts['master_job_cache'])](jid, job_load, minions=self.targets.keys()) + else: + self.returners['{0}.save_load'.format(self.opts['master_job_cache'])](jid, job_load) except Exception as exc: log.error('Could not save load with returner {0}: {1}'.format(self.opts['master_job_cache'], exc)) diff --git a/salt/returners/local_cache.py b/salt/returners/local_cache.py index a37597caf9..63a71f4eec 100644 --- a/salt/returners/local_cache.py +++ b/salt/returners/local_cache.py @@ -173,9 +173,13 @@ def returner(load): ) -def save_load(jid, clear_load): +def save_load(jid, clear_load, minions=None): ''' Save the load to the specified jid + + minions argument is to provide a pre-computed list of matched minions for + the job, for cases when this function can't compute that list itself (such + as for salt-ssh) ''' jid_dir = _jid_dir(jid) @@ -202,12 +206,13 @@ def save_load(jid, clear_load): # if you have a tgt, save that for the UI etc if 'tgt' in clear_load: - ckminions = salt.utils.minions.CkMinions(__opts__) - # Retrieve the minions list - minions = ckminions.check_minions( - clear_load['tgt'], - clear_load.get('tgt_type', 'glob') - ) + if minions is None: + ckminions = salt.utils.minions.CkMinions(__opts__) + # Retrieve the minions list + minions = ckminions.check_minions( + clear_load['tgt'], + clear_load.get('tgt_type', 'glob') + ) # save the minions to a cache so we can see in the UI try: serial.dump(