]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: propagate environment variables to subprocesses 42590/head
authorYuxiang Zhu <vfreex@gmail.com>
Mon, 2 Aug 2021 16:53:26 +0000 (00:53 +0800)
committerYuxiang Zhu <vfreex@gmail.com>
Mon, 2 Aug 2021 16:57:25 +0000 (00:57 +0800)
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 <vfreex@gmail.com>
src/cephadm/cephadm

index ea9c316425f6fb2b53f6cb6625354245e98a3733..dd5d27ef324dd18227b7f9a4cf0e9f2d9db41d91 100755 (executable)
@@ -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
 
 ##################################