Merge pull request #527 from darko-poljak/shorten-ssh-control-path

Shorten ssh control path.
This commit is contained in:
Nico Schottelius 2017-05-31 15:25:14 +02:00 committed by GitHub
commit dc66d954d5
2 changed files with 13 additions and 5 deletions

View file

@ -27,6 +27,8 @@ import time
import itertools
import tempfile
import socket
import atexit
import shutil
import cdist
import cdist.hostsource
@ -92,7 +94,6 @@ class Config(object):
"failed: %s" % e))
args.manifest = initial_manifest_temp_path
import atexit
atexit.register(lambda: os.remove(initial_manifest_temp_path))
# default remote cmd patterns
@ -176,8 +177,15 @@ class Config(object):
" ".join(failed_hosts))
@classmethod
def _resolve_remote_cmds(cls, args, host_base_path):
control_path = os.path.join(host_base_path, "ssh-control-path")
def _resolve_ssh_control_path(cls):
base_path = tempfile.mkdtemp()
control_path = os.path.join(base_path, "s")
atexit.register(lambda: shutil.rmtree(base_path))
return control_path
@classmethod
def _resolve_remote_cmds(cls, args):
control_path = cls._resolve_ssh_control_path()
# If we constructed patterns for remote commands then there is
# placeholder for ssh ControlPath, format it and we have unique
# ControlPath for each host.
@ -200,8 +208,7 @@ class Config(object):
log = logging.getLogger(host)
try:
remote_exec, remote_copy = cls._resolve_remote_cmds(
args, host_base_path)
remote_exec, remote_copy = cls._resolve_remote_cmds(args)
log.debug("remote_exec for host \"{}\": {}".format(
host, remote_exec))
log.debug("remote_copy for host \"{}\": {}".format(

View file

@ -6,6 +6,7 @@ next:
* Type __go_get: Install go packages using go get (Kamila Součková)
* Explorer kernel_name: uname -s (Kamila Součková)
* Type __sysctl: Add devuan support (Nico Schottelius)
* Core: Shorten ssh control path (Darko Poljak)
4.4.2: 2017-03-08
* Core: Fix suppression of manifests' outputs (Darko Poljak)