From 480e4d9fe24e80ffd4d8989234abf1206fb8d351 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 5 Jul 2021 05:36:38 +0000 Subject: [PATCH 1/7] Bump cherrypy from 18.1.0 to 18.6.1 Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.1.0 to 18.6.1. - [Release notes](https://github.com/cherrypy/cherrypy/releases) - [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst) - [Commits](https://github.com/cherrypy/cherrypy/compare/v18.1.0...v18.6.1) Signed-off-by: dependabot-preview[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index af09903..8a515b3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,4 +3,4 @@ tox==3.21.4 black==19.10b0 pylint==2.6.0 SaltPylint==2020.9.28 -CherryPy==18.1.0 +CherryPy==18.6.1 From fd9570ecc4c9dd77a7c5d50dfa7c88c31c149697 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 3 Aug 2021 05:36:53 +0000 Subject: [PATCH 2/7] Bump tox from 3.21.4 to 3.24.1 Bumps [tox](https://github.com/tox-dev/tox) from 3.21.4 to 3.24.1. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/3.21.4...3.24.1) Signed-off-by: dependabot-preview[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index af09903..89a5d68 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements.txt -tox==3.21.4 +tox==3.24.1 black==19.10b0 pylint==2.6.0 SaltPylint==2020.9.28 From 6b2d86ed138a1dd26c45020594e537e539283c27 Mon Sep 17 00:00:00 2001 From: Chris Hills Date: Fri, 9 Sep 2022 16:09:30 +0100 Subject: [PATCH 3/7] Fix 263: Salt3005rc1 raises AttributeError: 'SaltStandaloneProxy' object has no attribute 'setup_logfile_logger' --- salt_sproxy/cli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/salt_sproxy/cli.py b/salt_sproxy/cli.py index fab2f06..d87a41b 100644 --- a/salt_sproxy/cli.py +++ b/salt_sproxy/cli.py @@ -30,6 +30,7 @@ from salt.ext import six import salt.defaults.exitcodes # pylint: disable=W0611 import salt.utils.stringutils +import salt.version try: from salt.utils.files import fopen @@ -62,9 +63,11 @@ def run(self): sys.stdout.write(safe_dump(self.config, default_flow_style=False)) return self.config - # Setup file logging! - self.setup_logfile_logger() - verify_log(self.config) + if salt.version.__saltstack_version__.major < 3005: + # Setup file logging! + self.setup_logfile_logger() + verify_log(self.config) + profiling_enabled = self.options.profiling_enabled curpath = os.path.dirname(os.path.realpath(__file__)) saltenv = self.config.get('saltenv_cli', self.config.get('saltenv')) From 02a937b922c6d436eab7486bc3e7b549964b5d56 Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Wed, 19 Oct 2022 12:17:33 +0100 Subject: [PATCH 4/7] Adapt cache calls to Salt 3004+ It seems like after Salt 3003 or 3004, the cache is stored under a single file, data.p, which is different than the previous behaviour where we had separate files for Grains and Pillar. --- salt_sproxy/_runners/proxy.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/salt_sproxy/_runners/proxy.py b/salt_sproxy/_runners/proxy.py index 8a85a50..792da7f 100644 --- a/salt_sproxy/_runners/proxy.py +++ b/salt_sproxy/_runners/proxy.py @@ -621,9 +621,11 @@ def salt_call( opts['proxy_test_ping'] = test_ping opts['proxy_use_cached_grains'] = use_cached_grains if use_cached_grains: - opts['proxy_cached_grains'] = __salt__['cache.fetch']( - 'minions/{}/data'.format(minion_id), 'grains' + cache_data = __salt__['cache.fetch']( + 'minions/{}'.format(minion_id), 'data' ) + if cache_data and 'grains' in cache_data: + opts['proxy_cached_grains'] = cache_data['grains'] opts['roster_opts'] = roster_opts opts['returner'] = returner if not returner_kwargs: @@ -702,17 +704,17 @@ def salt_call( log.warning( 'Returner %s is not available. Check that the dependencies are properly installed' ) + cache_data = {} if cache_grains: log.debug('Caching Grains for %s', minion_id) log.debug(sa_proxy.opts['grains']) - cache_store = __salt__['cache.store']( - 'minions/{}/data'.format(minion_id), 'grains', sa_proxy.opts['grains'] - ) + cache_data['grains'] = copy.deepcopy(sa_proxy.opts['grains']) if cache_pillar: log.debug('Caching Pillar for %s', minion_id) - cached_store = __salt__['cache.store']( - 'minions/{}/data'.format(minion_id), 'pillar', sa_proxy.opts['pillar'] - ) + cache_data['pillar'] = copy.deepcopy(sa_proxy.opts['pillar']) + cached_store = __salt__['cache.store']( + 'minions/{}'.format(minion_id), 'data', cache_data + ) return ret, retcode From 580dced780edd6d00ff3d7d665b20c86af08886b Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Wed, 19 Oct 2022 11:55:28 +0100 Subject: [PATCH 5/7] Work around recent core changes, causing unnecesary ping --- salt_sproxy/_runners/proxy.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/salt_sproxy/_runners/proxy.py b/salt_sproxy/_runners/proxy.py index 792da7f..87a15de 100644 --- a/salt_sproxy/_runners/proxy.py +++ b/salt_sproxy/_runners/proxy.py @@ -207,6 +207,22 @@ def _receive_replies_sync(ret_queue, static_queue, done_queue, progress_bar): done_queue.put(_SENTINEL) +class PingBatch(Batch): + def __init__( + self, opts, eauth=None, quiet=False, parser=None + ): # pylint: disable=super-init-not-called + self.opts = opts + self.eauth = eauth if eauth else {} + self.pub_kwargs = eauth if eauth else {} + self.quiet = quiet + self.local = salt.client.get_local_client(opts['conf_file']) + self.minions, self.ping_gen, self.down_minions = self.gather_minions() + self.options = parser + + def _gather_minions(self): + return self.minions, self.ping_gen, self.down_minions + + class NoPingBatch(Batch): ''' Similar to the native Salt Batch. but without issuing test.ping to ensure @@ -221,11 +237,11 @@ def __init__( self.pub_kwargs = eauth if eauth else {} self.quiet = quiet self.local = salt.client.get_local_client(opts['conf_file']) - self.minions, self.ping_gen, self.down_minions = self.__gather_minions() + self.minions, self.ping_gen, self.down_minions = self.opts['tgt'], [], [] self.options = parser - def __gather_minions(self): - return self.opts['tgt'], [], [] + def gather_minions(self): + return self.minions, self.ping_gen, self.down_minions # The SProxyMinion class is back-ported from Salt 2019.2.0 (to be released soon) @@ -958,17 +974,19 @@ def execute_devices( log.debug(existing_minions) batch_opts = copy.deepcopy(__opts__) batch_opts['batch'] = str(existing_batch_size) - batch_opts['tgt'] = existing_minions - batch_opts['tgt_type'] = 'list' + batch_opts['tgt'] = tgt + batch_opts['tgt_type'] = tgt_type batch_opts['fun'] = salt_function batch_opts['arg'] = event_args batch_opts['batch_wait'] = batch_wait - batch_opts['selected_target_option'] = 'list' + batch_opts['selected_target_option'] = tgt_type batch_opts['return'] = returner batch_opts['ret_config'] = returner_config batch_opts['ret_kwargs'] = returner_kwargs if test_ping: - cli_batch = Batch(batch_opts, quiet=True) + cli_batch = PingBatch(batch_opts, quiet=True) + cli_batch.minions, cli_batch.ping_gen, cli_batch.down_minions = cli_batch.gather_minions() + cli_batch.gather_minions = cli_batch._gather_minions else: cli_batch = NoPingBatch(batch_opts, quiet=True) log.debug('Batching detected the following Minions responsive') From 221d12dde4d44f4e47349419e4dad60df7fd2d3c Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Thu, 20 Oct 2022 11:25:37 +0100 Subject: [PATCH 6/7] Don't change the targeting mechanism --- salt_sproxy/_runners/proxy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt_sproxy/_runners/proxy.py b/salt_sproxy/_runners/proxy.py index 87a15de..64fde1d 100644 --- a/salt_sproxy/_runners/proxy.py +++ b/salt_sproxy/_runners/proxy.py @@ -974,12 +974,12 @@ def execute_devices( log.debug(existing_minions) batch_opts = copy.deepcopy(__opts__) batch_opts['batch'] = str(existing_batch_size) - batch_opts['tgt'] = tgt - batch_opts['tgt_type'] = tgt_type + batch_opts['tgt'] = existing_minions + batch_opts['tgt_type'] = 'list' batch_opts['fun'] = salt_function batch_opts['arg'] = event_args batch_opts['batch_wait'] = batch_wait - batch_opts['selected_target_option'] = tgt_type + batch_opts['selected_target_option'] = 'list' batch_opts['return'] = returner batch_opts['ret_config'] = returner_config batch_opts['ret_kwargs'] = returner_kwargs From da4a9a15c5b603d5f42423ed8cee88dee173ad91 Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Thu, 20 Oct 2022 11:30:56 +0100 Subject: [PATCH 7/7] Bump version to 2022.10.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9254995..bd584f6 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name=name, - version='2021.6.1', + version='2022.10.0', namespace_packages=['salt_sproxy'], packages=find_packages(), author='Mircea Ulinic',