From: Yuxiang Zhu Date: Mon, 2 Aug 2021 16:53:26 +0000 (+0800) Subject: cephadm: propagate environment variables to subprocesses X-Git-Tag: v16.2.6~25^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b86c8de3db88efa66d960aa7501c241199e516da;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 (cherry picked from commit 8f72f774892be6aec458452fc2678578f2436e90) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 252cc1a48593..4be920db8e0c 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1425,7 +1425,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: @@ -1474,7 +1475,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) @@ -4789,7 +4790,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 ##################################