-------------------
Mitogen for Ansible
~~~~~~~~~~~~~~~~~~~
This release includes a huge variety of important fixes and new optimizations.
It is 35% faster than 0.2.3 on a synthetic 64 target run that places heavy load
on the connection multiplexer.
Enhancements
^^^^^^^^^^^^
* :gh:issue:`76`,
:gh:issue:`351`,
:gh:issue:`352`: disconnect propagation
has improved, allowing Ansible to cancel waits for responses from abruptly
disconnected targets. This ensures a task will reliably fail rather than
hang, for example on network failure or EC2 instance maintenance.
* :gh:issue:`369`,
:gh:issue:`407`: :meth:`Connection.reset`
is implemented, allowing :ans:mod:`meta: reset_connection <meta>` to shut
down the remote interpreter as documented, and improving support for the
:ans:mod:`reboot`.
* :gh:commit:`09aa27a6`: the
``mitogen_host_pinned`` strategy wraps the ``host_pinned`` strategy
introduced in Ansible 2.7.
* :gh:issue:`477`: Python 2.4 is fully
supported by the core library and tested automatically, in any parent/child
combination of 2.4, 2.6, 2.7 and 3.6 interpreters.
* :gh:issue:`477`: Ansible 2.3 is fully
supported and tested automatically. In combination with the core library
Python 2.4 support, this allows Red Hat Enterprise Linux 5 targets to be
managed with Mitogen. The ``simplejson`` package need not be installed on
such targets, as is usually required by Ansible.
* :gh:issue:`412`: to simplify diagnosing
connection configuration problems, Mitogen ships a ``mitogen_get_stack``
action that is automatically added to the action plug-in path. See
:ref:`mitogen-get-stack` for more information.
* :gh:commit:`152effc2`,
:gh:commit:`bd4b04ae`: a CPU affinity
policy was added for Linux controllers, reducing latency and SMP overhead on
hot paths exercised for every task. This yielded a 19% speedup in a 64-target
job composed of many short tasks, and should easily be visible as a runtime
improvement in many-host runs.
* :gh:commit:`2b44d598`: work around a
defective caching mechanism by pre-heating it before spawning workers. This
saves 40% runtime on a synthetic repetitive task.
* :gh:commit:`0979422a`: an expensive
dependency scanning step was redundantly invoked for every task,
bottlenecking the connection multiplexer.
* :gh:commit:`eaa990a97`: a new
``mitogen_ssh_compression`` variable is supported, allowing Mitogen's default
SSH compression to be disabled. SSH compression is a large contributor to CPU
usage in many-target runs, and severely limits file transfer. On a `"shell:
hostname"` task repeated 500 times, Mitogen requires around 800 bytes per
task with compression, rising to 3 KiB without. File transfer throughput
rises from ~25MiB/s when enabled to ~200MiB/s when disabled.
* :gh:issue:`260`,
:gh:commit:`a18a083c`: brokers no
longer wait for readiness indication to transmit, and instead assume
transmission will succeed. As this is usually true, one loop iteration and
two poller reconfigurations are avoided, yielding a significant reduction in
interprocess round-trip latency.
* :gh:issue:`415`, :gh:issue:`491`, :gh:issue:`493`: the interface employed
for in-process queues changed from :freebsd:man2:`kqueue` /
:linux:man7:`epoll` to :linux:man2:`poll`, which requires no setup or
teardown, yielding a 38% latency reduction for inter-thread communication.
Fixes
^^^^^
* :gh:issue:`251`,
:gh:issue:`359`,
:gh:issue:`396`,
:gh:issue:`401`,
:gh:issue:`404`,
:gh:issue:`412`,
:gh:issue:`434`,
:gh:issue:`436`,
:gh:issue:`465`: connection delegation and
``delegate_to:`` handling suffered a major regression in 0.2.3. The 0.2.2
behaviour has been restored, and further work has been made to improve the
compatibility of connection delegation's configuration building methods.
* :gh:issue:`323`,
:gh:issue:`333`: work around a Windows
Subsystem for Linux bug that caused tracebacks to appear during shutdown.
* :gh:issue:`334`: the SSH method
tilde-expands private key paths using Ansible's logic. Previously the path
was passed unmodified to SSH, which expanded it using :func:`pwd.getpwnam`.
This differs from :func:`os.path.expanduser`, which uses the ``HOME``
environment variable if it is set, causing behaviour to diverge when Ansible
was invoked across user accounts via ``sudo``.
* :gh:issue:`364`: file transfers from
controllers running Python 2.7.2 or earlier could be interrupted due to a
forking bug in the :mod:`tempfile` module.
* :gh:issue:`370`: the Ansible :ans:mod:`reboot` is supported.
* :gh:issue:`373`: the LXC and LXD methods print a useful hint on failure, as
no useful error is normally logged to the console by these tools.
* :gh:issue:`374`,
:gh:issue:`391`: file transfer and module
execution from 2.x controllers to 3.x targets was broken due to a regression
caused by refactoring, and compounded by :gh:issue:`426`.
* :gh:issue:`400`: work around a threading
bug in the AWX display callback when running with high verbosity setting.
* :gh:issue:`409`: the setns method was
silently broken due to missing tests. Basic coverage was added to prevent a
recurrence.
* :gh:issue:`409`: the LXC and LXD methods
support ``mitogen_lxc_path`` and ``mitogen_lxc_attach_path`` variables to
control the location of third pary utilities.
* :gh:issue:`410`: the sudo method supports
the SELinux ``--type`` and ``--role`` options.
* :gh:issue:`420`: if a :class:`Connection`
was constructed in the Ansible top-level process, for example while executing
``meta: reset_connection``, resources could become undesirably shared in
subsequent children.
* :gh:issue:`426`: an oversight while
porting to Python 3 meant no automated 2->3 tests were running. A significant
number of 2->3 bugs were fixed, mostly in the form of Unicode/bytes
mismatches.
* :gh:issue:`429`: the ``sudo`` method can
now recognize internationalized password prompts.
* :gh:issue:`362`,
:gh:issue:`435`: the previous fix for slow
Python 2.x subprocess creation on Red Hat caused newly spawned children to
have a reduced open files limit. A more intrusive fix has been added to
directly address the problem without modifying the subprocess environment.
* :gh:issue:`397`,
:gh:issue:`454`: the previous approach to
handling modern Ansible temporary file cleanup was too aggressive, and could
trigger early finalization of Cython-based extension modules, leading to
segmentation faults.
* :gh:issue:`499`: the ``allow_same_user``
Ansible configuration setting is respected.
* :gh:issue:`527`: crashes in modules are
trapped and reported in a manner that matches Ansible. In particular, a
module crash no longer leads to an exception that may crash the corresponding
action plug-in.
* :gh:commit:`dc1d4251`: the :ans:mod:`synchronize` could fail with the Docker
transport due to a missing attribute.
* :gh:commit:`599da068`: fix a race
when starting async tasks, where it was possible for the controller to
observe no status file on disk before the task had a chance to write one.
* :gh:commit:`2c7af9f04`: Ansible
modules were repeatedly re-transferred. The bug was hidden by the previously
mandatorily enabled SSH compression.
Core Library
~~~~~~~~~~~~
* :gh:issue:`76`: routing records the
destination context IDs ever received on each stream, and when disconnection
occurs, propagates :data:`mitogen.core.DEL_ROUTE` messages towards every
stream that ever communicated with the disappearing peer, rather than simply
towards parents. Conversations between nodes anywhere in the tree receive
:data:`mitogen.core.DEL_ROUTE` when either participant disconnects, allowing
receivers to wake with :class:`mitogen.core.ChannelError`, even when one
participant is not a parent of the other.
* :gh:issue:`109`,
:gh:commit:`57504ba6`: newer Python 3
releases explicitly populate :data:`sys.meta_path` with importer internals,
causing Mitogen to install itself at the end of the importer chain rather
than the front.
* :gh:issue:`310`: support has returned for
trying to figure out the real source of non-module objects installed in
:data:`sys.modules`, so they can be imported. This is needed to handle syntax
sugar used by packages like :mod:`plumbum`.
* :gh:issue:`349`: an incorrect format
string could cause large stack traces when attempting to import built-in
modules on Python 3.
* :gh:issue:`387`,
:gh:issue:`413`: dead messages include an
optional reason in their body. This is used to cause
:class:`mitogen.core.ChannelError` to report far more useful diagnostics at
the point the error occurs that previously would have been buried in debug
log output from an unrelated context.
* :gh:issue:`408`: a variety of fixes were
made to restore Python 2.4 compatibility.
* :gh:issue:`399`,
:gh:issue:`437`: ignore a
:class:`DeprecationWarning` to avoid failure of the ``su`` method on Python
3.7.
* :gh:issue:`405`: if an oversized message
is rejected, and it has a ``reply_to`` set, a dead message is returned to the
sender. This ensures function calls exceeding the configured maximum size
crash rather than hang.
* :gh:issue:`406`:
:class:`mitogen.core.Broker` did not call :meth:`mitogen.core.Poller.close`
during shutdown, leaking the underlying poller FD in masters and parents.
* :gh:issue:`406`: connections could leak
FDs when a child process failed to start.
* :gh:issue:`288`,
:gh:issue:`406`,
:gh:issue:`417`: connections could leave
FD wrapper objects that had not been closed lying around to be closed during
garbage collection, causing reused FD numbers to be closed at random moments.
* :gh:issue:`411`: the SSH method typed
"``y``" rather than the requisite "``yes``" when `check_host_keys="accept"`
was configured. This would lead to connection timeouts due to the hung
response.
* :gh:issue:`414`,
:gh:issue:`425`: avoid deadlock of forked
children by reinitializing the :mod:`mitogen.service` pool lock.
* :gh:issue:`416`: around 1.4KiB of memory
was leaked on every RPC, due to a list of strong references keeping alive any
handler ever registered for disconnect notification.
* :gh:issue:`418`: the
:func:`mitogen.parent.iter_read` helper would leak poller FDs, because
execution of its :keyword:`finally` block was delayed on Python 3. Now
callers explicitly close the generator when finished.
* :gh:issue:`422`: the fork method could
fail to start if :data:`sys.stdout` was opened in block buffered mode, and
buffered data was pending in the parent prior to fork.
* :gh:issue:`438`: a descriptive error is
logged when stream corruption is detected.
* :gh:issue:`439`: descriptive errors are
raised when attempting to invoke unsupported function types.
* :gh:issue:`444`: messages regarding
unforwardable extension module are no longer logged as errors.
* :gh:issue:`445`: service pools unregister
the :data:`mitogen.core.CALL_SERVICE` handle at shutdown, ensuring any
outstanding messages are either processed by the pool as it shuts down, or
have dead messages sent in reply to them, preventing peer contexts from
hanging due to a forgotten buffered message.
* :gh:issue:`446`: given thread A calling
:meth:`mitogen.core.Receiver.close`, and thread B, C, and D sleeping in
:meth:`mitogen.core.Receiver.get`, previously only one sleeping thread would
be woken with :class:`mitogen.core.ChannelError` when the receiver was
closed. Now all threads are woken per the docstring.
* :gh:issue:`447`: duplicate attempts to
invoke :meth:`mitogen.core.Router.add_handler` cause an error to be raised,
ensuring accidental re-registration of service pools are reported correctly.
* :gh:issue:`448`: the import hook
implementation now raises :class:`ModuleNotFoundError` instead of
:class:`ImportError` in Python 3.6 and above, to cope with an upcoming
version of the :mod:`subprocess` module requiring this new subclass to be
raised.
* :gh:issue:`453`: the loggers used in
children for standard IO redirection have propagation disabled, preventing
accidental reconfiguration of the :mod:`logging` package in a child from
setting up a feedback loop.
* :gh:issue:`456`: a descriptive error is
logged when :meth:`mitogen.core.Broker.defer` is called after the broker has
shut down, preventing new messages being enqueued that will never be sent,
and subsequently producing a program hang.
* :gh:issue:`459`: the beginnings of a
:meth:`mitogen.master.Router.get_stats` call has been added. The initial
statistics cover the module loader only.
* :gh:issue:`462`: Mitogen could fail to
open a PTY on broken Linux systems due to a bad interaction between the glibc
:func:`grantpt` function and an incorrectly mounted ``/dev/pts`` filesystem.
Since correct group ownership is not required in most scenarios, when this
problem is detected, the PTY is allocated and opened directly by the library.
* :gh:issue:`479`: Mitogen could fail to
import :mod:`__main__` on Python 3.4 and newer due to a breaking change in
the :mod:`pkgutil` API. The program's main script is now handled specially.
* :gh:issue:`481`: the version of `sudo`
that shipped with CentOS 5 replaced itself with the program to be executed,
and therefore did not hold any child PTY open on our behalf. The child
context is updated to preserve any PTY FD in order to avoid the kernel
sending `SIGHUP` early during startup.
* :gh:issue:`523`: the test suite didn't
generate a code coverage report if any test failed.
* :gh:issue:`524`: Python 3.6+ emitted a
:class:`DeprecationWarning` for :func:`mitogen.utils.run_with_router`.
* :gh:issue:`529`: Code coverage of the
test suite was not measured across all Python versions.
* :gh:commit:`16ca111e`: handle OpenSSH
7.5 permission denied prompts when ``~/.ssh/config`` rewrites are present.
* :gh:commit:`9ec360c2`: a new
:meth:`mitogen.core.Broker.defer_sync` utility function is provided.
* :gh:commit:`f20e0bba`:
:meth:`mitogen.service.FileService.register_prefix` permits granting
unprivileged access to whole filesystem subtrees, rather than single files at
a time.
* :gh:commit:`8f85ee03`:
:meth:`mitogen.core.Router.myself` returns a :class:`mitogen.core.Context`
referring to the current process.
* :gh:commit:`824c7931`: exceptions
raised by the import hook were updated to include probable reasons for
a failure.
* :gh:commit:`57b652ed`: a stray import
meant an extra roundtrip and ~4KiB of data was wasted for any context that
imported :mod:`mitogen.parent`.
Thanks!
~~~~~~~
Mitogen would not be possible without the support of users. A huge thanks for
bug reports, testing, features and fixes in this release contributed by
`Alex Willmer <https://github.com/moreati>`_,
`Andreas Krüger <https://github.com/woopstar>`_,
`Anton Stroganov <https://github.com/Aeon>`_,
`Berend De Schouwer <https://github.com/berenddeschouwer>`_,
`Brian Candler <https://github.com/candlerb>`_,
`dsgnr <https://github.com/dsgnr>`_,
`Duane Zamrok <https://github.com/dewthefifth>`_,
`Eric Chang <https://github.com/changchichung>`_,
`Gerben Meijer <https://github.com/infernix>`_,
`Guy Knights <https://github.com/knightsg>`_,
`Jesse London <https://github.com/jesteria>`_,
`Jiří Vávra <https://github.com/Houbovo>`_,
`Johan Beisser <https://github.com/jbeisser>`_,
`Jonathan Rosser <https://github.com/jrosser>`_,
`Josh Smift <https://github.com/jbscare>`_,
`Kevin Carter <https://github.com/cloudnull>`_,
`Mehdi <https://github.com/mehdisat7>`_,
`Michael DeHaan <https://github.com/mpdehaan>`_,
`Michal Medvecky <https://github.com/michalmedvecky>`_,
`Mohammed Naser <https://github.com/mnaser/>`_,
`Peter V. Saveliev <https://github.com/svinota/>`_,
`Pieter Avonts <https://github.com/pieteravonts/>`_,
`Ross Williams <https://github.com/overhacked/>`_,
`Sergey <https://github.com/LuckySB/>`_,
`Stéphane <https://github.com/sboisson/>`_,
`Strahinja Kustudic <https://github.com/kustodian>`_,
`Tom Parker-Shemilt <https://github.com/palfrey/>`_,
`Younès HAFRI <https://github.com/yhafri>`_,
`killua-eu <https://github.com/killua-eu>`_,
`myssa91 <https://github.com/myssa91>`_,
`ohmer1 <https://github.com/ohmer1>`_,
`s3c70r <https://github.com/s3c70r/>`_,
`syntonym <https://github.com/syntonym/>`_,
`trim777 <https://github.com/trim777/>`_,
`whky <https://github.com/whky/>`_, and
`yodatak <https://github.com/yodatak/>`_.