Shorten ssh control path.

On macos the path is too long due to long default TMP dir.
This commit is contained in:
Darko Poljak 2017-05-31 09:55:33 +02:00
parent 1322e85eac
commit 29bebc4af4
2 changed files with 13 additions and 5 deletions

View file

@ -27,6 +27,8 @@ import time
import itertools import itertools
import tempfile import tempfile
import socket import socket
import atexit
import shutil
import cdist import cdist
import cdist.hostsource import cdist.hostsource
@ -92,7 +94,6 @@ class Config(object):
"failed: %s" % e)) "failed: %s" % e))
args.manifest = initial_manifest_temp_path args.manifest = initial_manifest_temp_path
import atexit
atexit.register(lambda: os.remove(initial_manifest_temp_path)) atexit.register(lambda: os.remove(initial_manifest_temp_path))
# default remote cmd patterns # default remote cmd patterns
@ -176,8 +177,15 @@ class Config(object):
" ".join(failed_hosts)) " ".join(failed_hosts))
@classmethod @classmethod
def _resolve_remote_cmds(cls, args, host_base_path): def _resolve_ssh_control_path(cls):
control_path = os.path.join(host_base_path, "ssh-control-path") 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 # If we constructed patterns for remote commands then there is
# placeholder for ssh ControlPath, format it and we have unique # placeholder for ssh ControlPath, format it and we have unique
# ControlPath for each host. # ControlPath for each host.
@ -200,8 +208,7 @@ class Config(object):
log = logging.getLogger(host) log = logging.getLogger(host)
try: try:
remote_exec, remote_copy = cls._resolve_remote_cmds( remote_exec, remote_copy = cls._resolve_remote_cmds(args)
args, host_base_path)
log.debug("remote_exec for host \"{}\": {}".format( log.debug("remote_exec for host \"{}\": {}".format(
host, remote_exec)) host, remote_exec))
log.debug("remote_copy for host \"{}\": {}".format( 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á) * Type __go_get: Install go packages using go get (Kamila Součková)
* Explorer kernel_name: uname -s (Kamila Součková) * Explorer kernel_name: uname -s (Kamila Součková)
* Type __sysctl: Add devuan support (Nico Schottelius) * Type __sysctl: Add devuan support (Nico Schottelius)
* Core: Shorten ssh control path (Darko Poljak)
4.4.2: 2017-03-08 4.4.2: 2017-03-08
* Core: Fix suppression of manifests' outputs (Darko Poljak) * Core: Fix suppression of manifests' outputs (Darko Poljak)