From: Yuxiang Zhu Date: Mon, 2 Aug 2021 16:53:26 +0000 (+0800) Subject: cephadm: propagate environment variables to subprocesses X-Git-Tag: v17.1.0~1084^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8f72f774892be6aec458452fc2678578f2436e90;p=ceph.git cephadm: propagate environment variables to subprocesses so that I can use an http(s) proxy for external network access when running cephadm. e.g. ```sh http_proxy=http://proxy:8080 https_proxy=http://proxy:8080 cephadm pull ``` Signed-off-by: Yuxiang Zhu --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index ea9c316425f6f..dd5d27ef324dd 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1418,7 +1418,8 @@ def call(ctx: CephadmContext, process = await asyncio.create_subprocess_exec( *command, stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE) + stderr=asyncio.subprocess.PIPE, + env=os.environ.copy()) assert process.stdout assert process.stderr try: @@ -1467,7 +1468,7 @@ def call_timeout(ctx, command, timeout): raise TimeoutExpired(msg) try: - return subprocess.call(command, timeout=timeout) + return subprocess.call(command, timeout=timeout, env=os.environ.copy()) except subprocess.TimeoutExpired: raise_timeout(command, timeout) @@ -4714,7 +4715,7 @@ def command_logs(ctx): # call this directly, without our wrapper, so that we get an unmolested # stdout with logger prefixing. logger.debug('Running command: %s' % ' '.join(cmd)) - subprocess.call(cmd) # type: ignore + subprocess.call(cmd, env=os.environ.copy()) # type: ignore ##################################