From b86c8de3db88efa66d960aa7501c241199e516da Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Tue, 3 Aug 2021 00:53:26 +0800 Subject: [PATCH] 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) --- src/cephadm/cephadm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 252cc1a48593a..4be920db8e0c5 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 ################################## -- 2.39.5