Skip to content

Commit 2516429

Browse files
committed
Merge remote-tracking branch 'origin/v027' into stable
* 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
2 parents 407307a + 38b3415 commit 2516429

25 files changed

+304
-20
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the following checklist as a guide for what to include.
1010

1111
* Have you tried the latest master version from Git?
1212
* Do you have some idea of what the underlying problem may be?
13-
https://mitogen.rtfd.io/en/stable/ansible.html#common-problems has
13+
https://mitogen.networkgenomics.com/ansible_detailed.html#common-problems has
1414
instructions to help figure out the likely cause and how to gather relevant
1515
logs.
1616
* Mention your host and target OS and versions

ansible_mitogen/affinity.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import os
8080
import struct
8181

82+
import mitogen.core
8283
import mitogen.parent
8384

8485

@@ -246,8 +247,19 @@ def assign_subprocess(self):
246247

247248

248249
class LinuxPolicy(FixedPolicy):
250+
def _mask_to_bytes(self, mask):
251+
"""
252+
Convert the (type long) mask to a cpu_set_t.
253+
"""
254+
chunks = []
255+
shiftmask = (2 ** 64) - 1
256+
for x in range(16):
257+
chunks.append(struct.pack('<Q', mask & shiftmask))
258+
mask >>= 64
259+
return mitogen.core.b('').join(chunks)
260+
249261
def _set_cpu_mask(self, mask):
250-
s = struct.pack('L', mask)
262+
s = self._mask_to_bytes(mask)
251263
_sched_setaffinity(os.getpid(), len(s), s)
252264

253265

ansible_mitogen/connection.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@
5858
LOG = logging.getLogger(__name__)
5959

6060

61+
def get_remote_name(spec):
62+
"""
63+
Return the value to use for the "remote_name" parameter.
64+
"""
65+
if spec.mitogen_mask_remote_name():
66+
return 'ansible'
67+
return None
68+
69+
6170
def optional_int(value):
6271
"""
6372
Convert `value` to an integer if it is not :data:`None`, otherwise return
@@ -135,6 +144,7 @@ def _connect_ssh(spec):
135144
'connect_timeout': spec.ansible_ssh_timeout(),
136145
'ssh_args': spec.ssh_args(),
137146
'ssh_debug_level': spec.mitogen_ssh_debug_level(),
147+
'remote_name': get_remote_name(spec),
138148
}
139149
}
140150

@@ -150,6 +160,7 @@ def _connect_docker(spec):
150160
'container': spec.remote_addr(),
151161
'python_path': spec.python_path(),
152162
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
163+
'remote_name': get_remote_name(spec),
153164
}
154165
}
155166

@@ -166,6 +177,7 @@ def _connect_kubectl(spec):
166177
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
167178
'kubectl_path': spec.mitogen_kubectl_path(),
168179
'kubectl_args': spec.extra_args(),
180+
'remote_name': get_remote_name(spec),
169181
}
170182
}
171183

@@ -181,6 +193,7 @@ def _connect_jail(spec):
181193
'container': spec.remote_addr(),
182194
'python_path': spec.python_path(),
183195
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
196+
'remote_name': get_remote_name(spec),
184197
}
185198
}
186199

@@ -196,6 +209,7 @@ def _connect_lxc(spec):
196209
'python_path': spec.python_path(),
197210
'lxc_attach_path': spec.mitogen_lxc_attach_path(),
198211
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
212+
'remote_name': get_remote_name(spec),
199213
}
200214
}
201215

@@ -211,6 +225,7 @@ def _connect_lxd(spec):
211225
'python_path': spec.python_path(),
212226
'lxc_path': spec.mitogen_lxc_path(),
213227
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
228+
'remote_name': get_remote_name(spec),
214229
}
215230
}
216231

@@ -254,6 +269,7 @@ def _connect_su(spec):
254269
'python_path': spec.python_path(),
255270
'su_path': spec.become_exe(),
256271
'connect_timeout': spec.timeout(),
272+
'remote_name': get_remote_name(spec),
257273
}
258274
}
259275

@@ -272,6 +288,7 @@ def _connect_sudo(spec):
272288
'sudo_path': spec.become_exe(),
273289
'connect_timeout': spec.timeout(),
274290
'sudo_args': spec.sudo_args(),
291+
'remote_name': get_remote_name(spec),
275292
}
276293
}
277294

@@ -289,6 +306,7 @@ def _connect_doas(spec):
289306
'python_path': spec.python_path(),
290307
'doas_path': spec.become_exe(),
291308
'connect_timeout': spec.timeout(),
309+
'remote_name': get_remote_name(spec),
292310
}
293311
}
294312

@@ -305,6 +323,7 @@ def _connect_mitogen_su(spec):
305323
'python_path': spec.python_path(),
306324
'su_path': spec.become_exe(),
307325
'connect_timeout': spec.timeout(),
326+
'remote_name': get_remote_name(spec),
308327
}
309328
}
310329

@@ -322,6 +341,7 @@ def _connect_mitogen_sudo(spec):
322341
'sudo_path': spec.become_exe(),
323342
'connect_timeout': spec.timeout(),
324343
'sudo_args': spec.sudo_args(),
344+
'remote_name': get_remote_name(spec),
325345
}
326346
}
327347

@@ -338,6 +358,7 @@ def _connect_mitogen_doas(spec):
338358
'python_path': spec.python_path(),
339359
'doas_path': spec.become_exe(),
340360
'connect_timeout': spec.timeout(),
361+
'remote_name': get_remote_name(spec),
341362
}
342363
}
343364

ansible_mitogen/planner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def get_module_deps(self):
296296
#: manner.
297297
ALWAYS_FORK_MODULES = frozenset([
298298
'dnf', # issue #280; py-dnf/hawkey need therapy
299+
'firewalld', # issue #570: ansible module_utils caches dbus conn
299300
])
300301

301302
def should_fork(self):

ansible_mitogen/strategy.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,46 @@
3737
import ansible_mitogen.mixins
3838
import ansible_mitogen.process
3939

40+
import ansible
4041
import ansible.executor.process.worker
4142

4243

44+
ANSIBLE_VERSION_MIN = '2.3'
45+
ANSIBLE_VERSION_MAX = '2.7'
46+
NEW_VERSION_MSG = (
47+
"Your Ansible version (%s) is too recent. The most recent version\n"
48+
"supported by Mitogen for Ansible is %s.x. Please check the Mitogen\n"
49+
"release notes to see if a new version is available, otherwise\n"
50+
"subscribe to the corresponding GitHub issue to be notified when\n"
51+
"support becomes available.\n"
52+
"\n"
53+
" https://mitogen.rtfd.io/en/latest/changelog.html\n"
54+
" https://github.com/dw/mitogen/issues/\n"
55+
)
56+
OLD_VERSION_MSG = (
57+
"Your version of Ansible (%s) is too old. The oldest version supported by "
58+
"Mitogen for Ansible is %s."
59+
)
60+
61+
62+
def _assert_supported_release():
63+
"""
64+
Throw AnsibleError with a descriptive message in case of being loaded into
65+
an unsupported Ansible release.
66+
"""
67+
v = ansible.__version__
68+
69+
if v[:len(ANSIBLE_VERSION_MIN)] < ANSIBLE_VERSION_MIN:
70+
raise ansible.errors.AnsibleError(
71+
OLD_VERSION_MSG % (v, ANSIBLE_VERSION_MIN)
72+
)
73+
74+
if v[:len(ANSIBLE_VERSION_MAX)] > ANSIBLE_VERSION_MAX:
75+
raise ansible.errors.AnsibleError(
76+
NEW_VERSION_MSG % (ansible.__version__, ANSIBLE_VERSION_MAX)
77+
)
78+
79+
4380
def _patch_awx_callback():
4481
"""
4582
issue #400: AWX loads a display callback that suffers from thread-safety
@@ -245,6 +282,8 @@ def run(self, iterator, play_context, result=0):
245282
Arrange for a mitogen.master.Router to be available for the duration of
246283
the strategy's real run() method.
247284
"""
285+
_assert_supported_release()
286+
248287
ansible_mitogen.process.MuxProcess.start()
249288
run = super(StrategyMixin, self).run
250289
self._add_plugin_paths()

ansible_mitogen/target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
u"were mounted on 'noexec' filesystems.\n"
9494
u"\n"
9595
u"The following paths were tried:\n"
96-
u" %(namelist)s\n"
96+
u" %(paths)s\n"
9797
u"\n"
9898
u"Please check '-vvv' output for a log of individual path errors."
9999
)

ansible_mitogen/transport_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ def mitogen_kind(self):
231231
The type of container to use with the "setns" transport.
232232
"""
233233

234+
@abc.abstractmethod
235+
def mitogen_mask_remote_name(self):
236+
"""
237+
Specifies whether to set a fixed "remote_name" field. The remote_name
238+
is the suffix of `argv[0]` for remote interpreters. By default it
239+
includes identifying information from the local process, which may be
240+
undesirable in some circumstances.
241+
"""
242+
234243
@abc.abstractmethod
235244
def mitogen_docker_path(self):
236245
"""
@@ -385,6 +394,9 @@ def mitogen_via(self):
385394
def mitogen_kind(self):
386395
return self._connection.get_task_var('mitogen_kind')
387396

397+
def mitogen_mask_remote_name(self):
398+
return self._connection.get_task_var('mitogen_mask_remote_name')
399+
388400
def mitogen_docker_path(self):
389401
return self._connection.get_task_var('mitogen_docker_path')
390402

@@ -593,6 +605,9 @@ def mitogen_via(self):
593605
def mitogen_kind(self):
594606
return self._host_vars.get('mitogen_kind')
595607

608+
def mitogen_mask_remote_name(self):
609+
return self._host_vars.get('mitogen_mask_remote_name')
610+
596611
def mitogen_docker_path(self):
597612
return self._host_vars.get('mitogen_docker_path')
598613

docs/_templates/ansible.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<title>Mitogen for Ansible (Redirect)</title>
3+
<script>
4+
{% include "piwik-config.js" %}
5+
var u="https://networkgenomics.com/p/tr/";
6+
_paq.push(['setTrackerUrl', u+'ep']);
7+
</script>
8+
<script src="https://networkgenomics.com/p/tr/js"></script>
9+
<script>
10+
setTimeout(function() {
11+
window.location = 'https://networkgenomics.com/ansible/';
12+
}, 0);
13+
</script>
14+
<meta http-equiv="Refresh" content="0; url=https://networkgenomics.com/ansible/">

docs/_templates/layout.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
{{ super() }}
66

77
<script>
8-
var _paq = _paq || [];
9-
_paq.push(['trackPageView']);
10-
_paq.push(['enableLinkTracking']);
118
(function() {
9+
{% include "piwik-config.js" %}
1210
var u="https://k1.botanicus.net/tr/";
13-
_paq.push(['enableHeartBeatTimer', 30]);
1411
_paq.push(['setTrackerUrl', u+'ep']);
15-
_paq.push(['setSiteId', 6]);
1612
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
1713
g.defer=true; g.async=true; g.src=u+'js'; s.parentNode.insertBefore(g,s);
1814
})();

docs/_templates/piwik-config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
window._paq = [];
2+
window._paq.push(['trackPageView']);
3+
window._paq.push(['enableLinkTracking']);
4+
window._paq.push(['enableHeartBeatTimer', 30]);
5+
window._paq.push(['setSiteId', 6]);

0 commit comments

Comments
 (0)