]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: propagate environment variables to subprocesses
authorYuxiang Zhu <vfreex@gmail.com>
Mon, 2 Aug 2021 16:53:26 +0000 (00:53 +0800)
committerSebastian Wagner <sewagner@redhat.com>
Thu, 2 Sep 2021 14:24:39 +0000 (16:24 +0200)
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>
(cherry picked from commit 8f72f774892be6aec458452fc2678578f2436e90)

src/cephadm/cephadm

index 252cc1a48593a48b500217ef1e29b84ba00dc674..4be920db8e0c5eb1ec56f49185e75313000e774f 100755 (executable)
@@ -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
 
 ##################################