From 65deebdd5c98cc21e712669c2744bd7b2fe7d22c Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Tue, 17 Dec 2024 10:31:59 +0000 Subject: [PATCH] WIP --- .ci/ansible_tests.py | 5 -- .ci/localhost_ansible_tests.py | 5 -- .github/workflows/tests.yml | 60 +------------------ ansible_mitogen/connection.py | 17 +++++- ansible_mitogen/services.py | 8 ++- ansible_mitogen/strategy.py | 1 + ansible_mitogen/transport_config.py | 4 +- tests/ansible/all.yml | 4 -- tests/ansible/regression/all.yml | 19 ------ ..._109__target_has_old_ansible_installed.yml | 1 + tox.ini | 2 +- 11 files changed, 25 insertions(+), 101 deletions(-) diff --git a/.ci/ansible_tests.py b/.ci/ansible_tests.py index 4a7bedaeb..047f5fb92 100755 --- a/.ci/ansible_tests.py +++ b/.ci/ansible_tests.py @@ -26,11 +26,6 @@ def pause_if_interactive(): interesting = ci_lib.get_interesting_procs() -with ci_lib.Fold('unit_tests'): - os.environ['SKIP_MITOGEN'] = '1' - ci_lib.run('./run_tests -v') - - ci_lib.check_stray_processes(interesting) diff --git a/.ci/localhost_ansible_tests.py b/.ci/localhost_ansible_tests.py index e4b8329ba..10a697f09 100755 --- a/.ci/localhost_ansible_tests.py +++ b/.ci/localhost_ansible_tests.py @@ -16,11 +16,6 @@ KEY_PATH = os.path.join(TESTS_DIR, '../data/docker/mitogen__has_sudo_pubkey.key') -with ci_lib.Fold('unit_tests'): - os.environ['SKIP_MITOGEN'] = '1' - ci_lib.run('./run_tests -v') - - with ci_lib.Fold('job_setup'): os.chmod(KEY_PATH, int('0600', 8)) # NOTE: sshpass v1.06 causes errors so pegging to 1.05 -> "msg": "Error when changing password","out": "passwd: DS error: eDSAuthFailed\n", diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a275a00c..cfc1545a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ on: - docs-master env: - #ANSIBLE_VERBOSITY: 3 + ANSIBLE_VERBOSITY: 3 #MITOGEN_LOG_LEVEL: DEBUG MITOGEN_TEST_IMAGE_TEMPLATE: "ghcr.io/mitogen-hq/%(distro)s-test" @@ -24,62 +24,10 @@ jobs: fail-fast: false matrix: include: - - name: Ans_27_210 - tox_env: py27-mode_ansible-ansible2.10 - - name: Ans_27_4 - tox_env: py27-mode_ansible-ansible4 - - - name: Ans_36_210 - python_version: '3.6' - tox_env: py36-mode_ansible-ansible2.10 - - name: Ans_36_4 - python_version: '3.6' - tox_env: py36-mode_ansible-ansible4 - - - name: Ans_311_210 - python_version: '3.11' - tox_env: py311-mode_ansible-ansible2.10 - - name: Ans_311_3 - python_version: '3.11' - tox_env: py311-mode_ansible-ansible3 - - name: Ans_311_4 - python_version: '3.11' - tox_env: py311-mode_ansible-ansible4 - - name: Ans_311_5 - python_version: '3.11' - tox_env: py311-mode_ansible-ansible5 - - name: Ans_313_6 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible6 - - name: Ans_313_7 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible7 - - name: Ans_313_8 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible8 - - name: Ans_313_9 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible9 - - name: Ans_313_10 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible10 - name: Ans_313_11 python_version: '3.13' tox_env: py313-mode_ansible-ansible11 - - name: Van_313_11 - python_version: '3.13' - tox_env: py313-mode_ansible-ansible11-strategy_linear - - - name: Mito_27 - tox_env: py27-mode_mitogen - - name: Mito_36 - python_version: '3.6' - tox_env: py36-mode_mitogen - - name: Mito_313 - python_version: '3.13' - tox_env: py313-mode_mitogen - steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -171,12 +119,6 @@ jobs: - name: Mito_313 tox_env: py313-mode_mitogen - - name: Loc_313_11 - tox_env: py313-mode_localhost-ansible11 - - - name: Van_313_11 - tox_env: py313-mode_localhost-ansible11-strategy_linear - steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 5053a5f5b..09b542807 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -41,6 +41,7 @@ import ansible.constants as C import ansible.errors import ansible.plugins.connection +from ansible.utils.display import Display import mitogen.core @@ -53,6 +54,8 @@ import ansible_mitogen.utils.unsafe +display = Display() + LOG = logging.getLogger(__name__) task_vars_msg = ( @@ -958,13 +961,21 @@ def reset(self): self._action_monkey_patched_by_mitogen = True # Workaround for https://github.com/ansible/ansible/issues/84238 - self.set_options( - task_keys=task.dump_attrs(), - var_options=self._mitogen_var_options(templar), + task_keys = task.dump_attrs() + var_options = self._mitogen_var_options(templar) + display.warning( + 'foo task_keys/timeout=%r var_options/ansible_ssh_timeout=%r connection/timeout=%r' + % (task_keys.get('timeout', 'N/A'), var_options.get('ansible_ssh_timeout', 'N/A'), self.get_option('timeout')), ) + #task_keys['timeout'] = self._play_context.timeout + del task_keys['retries'] + self.set_options(task_keys=task_keys, var_options=var_options) + display.warning('bar %r' % self.get_option('timeout')) del task + del task_keys del templar + del var_options # Clear out state in case we were ever connected. self.close() diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index abc0e3794..c63e82003 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -171,8 +171,10 @@ def reset(self, stack): key = key_from_dict(via=context, **spec) response = self._response_by_key.get(key) if response is None: - LOG.debug('%r: could not find connection to shut down; ' - 'failed at hop %d', self, i) + LOG.warning('%r: could not find connection to shut down; ' + 'failed at hop %d, key %r', self, i, key) + LOG.warning('%r', stack) + LOG.warning('%r', self._response_by_key) return False context = response['context'] @@ -325,7 +327,7 @@ def _on_context_disconnect(self, context): """ self._lock.acquire() try: - LOG.info('%r: Forgetting %r due to stream disconnect', self, context) + #LOG.info('%r: Forgetting %r due to stream disconnect', self, context) self._forget_context_unlocked(context) finally: self._lock.release() diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py index c319f3e11..af8619830 100644 --- a/ansible_mitogen/strategy.py +++ b/ansible_mitogen/strategy.py @@ -337,6 +337,7 @@ def _smuggle_to_connction_reset(self, task, play_context, iterator, target_host) templar = ansible.template.Templar( loader=self._loader, variables=variables, ) + play_context.update_vars(variables) play_context.vars.update({ '_mitogen.smuggled.reset_connection': (task, templar), }) diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index 937755528..56defc31b 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -737,8 +737,8 @@ def timeout(self): def ansible_ssh_timeout(self): return ( - self._host_vars.get('ansible_timeout') or - self._host_vars.get('ansible_ssh_timeout') or + # self._host_vars.get('ansible_timeout') or + # self._host_vars.get('ansible_ssh_timeout') or self.timeout() ) diff --git a/tests/ansible/all.yml b/tests/ansible/all.yml index 7a3e70001..44ea7efd7 100644 --- a/tests/ansible/all.yml +++ b/tests/ansible/all.yml @@ -1,6 +1,2 @@ -- import_playbook: setup/all.yml - tags: setup - import_playbook: regression/all.yml tags: regression -- import_playbook: integration/all.yml - tags: integration diff --git a/tests/ansible/regression/all.yml b/tests/ansible/regression/all.yml index a7c8033e4..47dedfcaf 100644 --- a/tests/ansible/regression/all.yml +++ b/tests/ansible/regression/all.yml @@ -1,20 +1 @@ - import_playbook: issue_109__target_has_old_ansible_installed.yml -- import_playbook: issue_113__duplicate_module_imports.yml -- import_playbook: issue_118__script_not_marked_exec.yml -- import_playbook: issue_122__environment_difference.yml -- import_playbook: issue_140__thread_pileup.yml -- import_playbook: issue_152__local_action_wrong_interpreter.yml -- import_playbook: issue_152__virtualenv_python_fails.yml -- import_playbook: issue_154__module_state_leaks.yml -- import_playbook: issue_177__copy_module_failing.yml -- import_playbook: issue_332_ansiblemoduleerror_first_occurrence.yml -- import_playbook: issue_558_unarchive_failed.yml -- import_playbook: issue_590__sys_modules_crap.yml -- import_playbook: issue_591__setuptools_cwd_crash.yml -- import_playbook: issue_615__streaming_transfer.yml -- import_playbook: issue_655__wait_for_connection_error.yml -- import_playbook: issue_776__load_plugins_called_twice.yml -- import_playbook: issue_952__ask_become_pass.yml -- import_playbook: issue_1066__add_host__host_key_checking.yml -- import_playbook: issue_1079__wait_for_connection_timeout.yml -- import_playbook: issue_1087__template_streamerror.yml diff --git a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml index 064832ece..a7ae0908c 100644 --- a/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml +++ b/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml @@ -26,6 +26,7 @@ - env.cwd == ansible_user_dir - (not env.mitogen_loaded) or (env.python_path.count("") == 1) fail_msg: | + ansible_user_dir={{ ansible_user_dir }} env={{ env }} - name: Run some new-style from ansible.module_utils... modules diff --git a/tox.ini b/tox.ini index ea988aa0c..fa73ee45f 100644 --- a/tox.ini +++ b/tox.ini @@ -114,7 +114,7 @@ setenv = # Ansible 10 (ansible-core 2.17) requires Python >= 3.7 on targets ansible10: MITOGEN_TEST_DISTRO_SPECS=debian10-py3 debian11-py3 ubuntu2004-py3 # Ansible 11 (ansible-core 2.18) requires Python >= 3.8 on targets - ansible11: MITOGEN_TEST_DISTRO_SPECS=debian11-py3 ubuntu2004-py3 + ansible11: MITOGEN_TEST_DISTRO_SPECS=ubuntu2004-py3 distros_centos: MITOGEN_TEST_DISTRO_SPECS=centos6 centos7 centos8 distros_centos5: MITOGEN_TEST_DISTRO_SPECS=centos5 distros_centos6: MITOGEN_TEST_DISTRO_SPECS=centos6