Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v027' into stable
Browse files Browse the repository at this point in the history
* origin/v027:
  docs: update Changelog for release.
  Bump version for release.
  issue #587: update Changelog
  issue #587: ansible: descriptive version check during startup.
  ansible: descriptive version check during startup.
  issue #581: expose mitogen_mask_remote_name variable.
  issue #576: fix Kwargs minor version check.
  issue #574: fix ISSUE_TEMPLATE link
  issue #575: fix exception text rendering
  docs: remove infringing mark
  docs: fix config var scope
  docs: faster stats-preserving redirect
  docs: update ansible page
  issue #570: add firewalld to always-fork list for now.
  docs: removed excess word
  docs: fixed message routing example description
  docs: removed repeated word
  docs: update Changelog; closes #557.
  issue #557: support correct cpu_set_t size
  • Loading branch information
dw committed May 19, 2019
2 parents 407307a + 38b3415 commit 2516429
Show file tree
Hide file tree
Showing 25 changed files with 304 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Expand Up @@ -10,7 +10,7 @@ the following checklist as a guide for what to include.

* Have you tried the latest master version from Git?
* Do you have some idea of what the underlying problem may be?
https://mitogen.rtfd.io/en/stable/ansible.html#common-problems has
https://mitogen.networkgenomics.com/ansible_detailed.html#common-problems has
instructions to help figure out the likely cause and how to gather relevant
logs.
* Mention your host and target OS and versions
Expand Down
14 changes: 13 additions & 1 deletion ansible_mitogen/affinity.py
Expand Up @@ -79,6 +79,7 @@
import os
import struct

import mitogen.core
import mitogen.parent


Expand Down Expand Up @@ -246,8 +247,19 @@ def assign_subprocess(self):


class LinuxPolicy(FixedPolicy):
def _mask_to_bytes(self, mask):
"""
Convert the (type long) mask to a cpu_set_t.
"""
chunks = []
shiftmask = (2 ** 64) - 1
for x in range(16):
chunks.append(struct.pack('<Q', mask & shiftmask))
mask >>= 64
return mitogen.core.b('').join(chunks)

def _set_cpu_mask(self, mask):
s = struct.pack('L', mask)
s = self._mask_to_bytes(mask)
_sched_setaffinity(os.getpid(), len(s), s)


Expand Down
21 changes: 21 additions & 0 deletions ansible_mitogen/connection.py
Expand Up @@ -58,6 +58,15 @@
LOG = logging.getLogger(__name__)


def get_remote_name(spec):
"""
Return the value to use for the "remote_name" parameter.
"""
if spec.mitogen_mask_remote_name():
return 'ansible'
return None


def optional_int(value):
"""
Convert `value` to an integer if it is not :data:`None`, otherwise return
Expand Down Expand Up @@ -135,6 +144,7 @@ def _connect_ssh(spec):
'connect_timeout': spec.ansible_ssh_timeout(),
'ssh_args': spec.ssh_args(),
'ssh_debug_level': spec.mitogen_ssh_debug_level(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -150,6 +160,7 @@ def _connect_docker(spec):
'container': spec.remote_addr(),
'python_path': spec.python_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -166,6 +177,7 @@ def _connect_kubectl(spec):
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'kubectl_path': spec.mitogen_kubectl_path(),
'kubectl_args': spec.extra_args(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -181,6 +193,7 @@ def _connect_jail(spec):
'container': spec.remote_addr(),
'python_path': spec.python_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -196,6 +209,7 @@ def _connect_lxc(spec):
'python_path': spec.python_path(),
'lxc_attach_path': spec.mitogen_lxc_attach_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -211,6 +225,7 @@ def _connect_lxd(spec):
'python_path': spec.python_path(),
'lxc_path': spec.mitogen_lxc_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand Down Expand Up @@ -254,6 +269,7 @@ def _connect_su(spec):
'python_path': spec.python_path(),
'su_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -272,6 +288,7 @@ def _connect_sudo(spec):
'sudo_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'sudo_args': spec.sudo_args(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -289,6 +306,7 @@ def _connect_doas(spec):
'python_path': spec.python_path(),
'doas_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -305,6 +323,7 @@ def _connect_mitogen_su(spec):
'python_path': spec.python_path(),
'su_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -322,6 +341,7 @@ def _connect_mitogen_sudo(spec):
'sudo_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'sudo_args': spec.sudo_args(),
'remote_name': get_remote_name(spec),
}
}

Expand All @@ -338,6 +358,7 @@ def _connect_mitogen_doas(spec):
'python_path': spec.python_path(),
'doas_path': spec.become_exe(),
'connect_timeout': spec.timeout(),
'remote_name': get_remote_name(spec),
}
}

Expand Down
1 change: 1 addition & 0 deletions ansible_mitogen/planner.py
Expand Up @@ -296,6 +296,7 @@ def get_module_deps(self):
#: manner.
ALWAYS_FORK_MODULES = frozenset([
'dnf', # issue #280; py-dnf/hawkey need therapy
'firewalld', # issue #570: ansible module_utils caches dbus conn
])

def should_fork(self):
Expand Down
39 changes: 39 additions & 0 deletions ansible_mitogen/strategy.py
Expand Up @@ -37,9 +37,46 @@
import ansible_mitogen.mixins
import ansible_mitogen.process

import ansible
import ansible.executor.process.worker


ANSIBLE_VERSION_MIN = '2.3'
ANSIBLE_VERSION_MAX = '2.7'
NEW_VERSION_MSG = (
"Your Ansible version (%s) is too recent. The most recent version\n"
"supported by Mitogen for Ansible is %s.x. Please check the Mitogen\n"
"release notes to see if a new version is available, otherwise\n"
"subscribe to the corresponding GitHub issue to be notified when\n"
"support becomes available.\n"
"\n"
" https://mitogen.rtfd.io/en/latest/changelog.html\n"
" https://github.com/dw/mitogen/issues/\n"
)
OLD_VERSION_MSG = (
"Your version of Ansible (%s) is too old. The oldest version supported by "
"Mitogen for Ansible is %s."
)


def _assert_supported_release():
"""
Throw AnsibleError with a descriptive message in case of being loaded into
an unsupported Ansible release.
"""
v = ansible.__version__

if v[:len(ANSIBLE_VERSION_MIN)] < ANSIBLE_VERSION_MIN:
raise ansible.errors.AnsibleError(
OLD_VERSION_MSG % (v, ANSIBLE_VERSION_MIN)
)

if v[:len(ANSIBLE_VERSION_MAX)] > ANSIBLE_VERSION_MAX:
raise ansible.errors.AnsibleError(
NEW_VERSION_MSG % (ansible.__version__, ANSIBLE_VERSION_MAX)
)


def _patch_awx_callback():
"""
issue #400: AWX loads a display callback that suffers from thread-safety
Expand Down Expand Up @@ -245,6 +282,8 @@ def run(self, iterator, play_context, result=0):
Arrange for a mitogen.master.Router to be available for the duration of
the strategy's real run() method.
"""
_assert_supported_release()

ansible_mitogen.process.MuxProcess.start()
run = super(StrategyMixin, self).run
self._add_plugin_paths()
Expand Down
2 changes: 1 addition & 1 deletion ansible_mitogen/target.py
Expand Up @@ -93,7 +93,7 @@
u"were mounted on 'noexec' filesystems.\n"
u"\n"
u"The following paths were tried:\n"
u" %(namelist)s\n"
u" %(paths)s\n"
u"\n"
u"Please check '-vvv' output for a log of individual path errors."
)
Expand Down
15 changes: 15 additions & 0 deletions ansible_mitogen/transport_config.py
Expand Up @@ -231,6 +231,15 @@ def mitogen_kind(self):
The type of container to use with the "setns" transport.
"""

@abc.abstractmethod
def mitogen_mask_remote_name(self):
"""
Specifies whether to set a fixed "remote_name" field. The remote_name
is the suffix of `argv[0]` for remote interpreters. By default it
includes identifying information from the local process, which may be
undesirable in some circumstances.
"""

@abc.abstractmethod
def mitogen_docker_path(self):
"""
Expand Down Expand Up @@ -385,6 +394,9 @@ def mitogen_via(self):
def mitogen_kind(self):
return self._connection.get_task_var('mitogen_kind')

def mitogen_mask_remote_name(self):
return self._connection.get_task_var('mitogen_mask_remote_name')

def mitogen_docker_path(self):
return self._connection.get_task_var('mitogen_docker_path')

Expand Down Expand Up @@ -593,6 +605,9 @@ def mitogen_via(self):
def mitogen_kind(self):
return self._host_vars.get('mitogen_kind')

def mitogen_mask_remote_name(self):
return self._host_vars.get('mitogen_mask_remote_name')

def mitogen_docker_path(self):
return self._host_vars.get('mitogen_docker_path')

Expand Down
14 changes: 14 additions & 0 deletions docs/_templates/ansible.html
@@ -0,0 +1,14 @@
<!doctype html>
<title>Mitogen for Ansible (Redirect)</title>
<script>
{% include "piwik-config.js" %}
var u="https://networkgenomics.com/p/tr/";
_paq.push(['setTrackerUrl', u+'ep']);
</script>
<script src="https://networkgenomics.com/p/tr/js"></script>
<script>
setTimeout(function() {
window.location = 'https://networkgenomics.com/ansible/';
}, 0);
</script>
<meta http-equiv="Refresh" content="0; url=https://networkgenomics.com/ansible/">
6 changes: 1 addition & 5 deletions docs/_templates/layout.html
Expand Up @@ -5,14 +5,10 @@
{{ super() }}

<script>
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
{% include "piwik-config.js" %}
var u="https://k1.botanicus.net/tr/";
_paq.push(['enableHeartBeatTimer', 30]);
_paq.push(['setTrackerUrl', u+'ep']);
_paq.push(['setSiteId', 6]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'js'; s.parentNode.insertBefore(g,s);
})();
Expand Down
5 changes: 5 additions & 0 deletions docs/_templates/piwik-config.js
@@ -0,0 +1,5 @@
window._paq = [];
window._paq.push(['trackPageView']);
window._paq.push(['enableLinkTracking']);
window._paq.push(['enableHeartBeatTimer', 30]);
window._paq.push(['setSiteId', 6]);

0 comments on commit 2516429

Please sign in to comment.