Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
moreati committed Dec 17, 2024
1 parent 2e9e6a7 commit 65deebd
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 101 deletions.
5 changes: 0 additions & 5 deletions .ci/ansible_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
5 changes: 0 additions & 5 deletions .ci/localhost_ansible_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
60 changes: 1 addition & 59 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions ansible_mitogen/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -53,6 +54,8 @@
import ansible_mitogen.utils.unsafe


display = Display()

LOG = logging.getLogger(__name__)

task_vars_msg = (
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions ansible_mitogen/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions ansible_mitogen/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
Expand Down
4 changes: 2 additions & 2 deletions ansible_mitogen/transport_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)

Expand Down
4 changes: 0 additions & 4 deletions tests/ansible/all.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 0 additions & 19 deletions tests/ansible/regression/all.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65deebd

Please sign in to comment.