diff --git a/gnes/cli/parser.py b/gnes/cli/parser.py index 14bb238f..868f9cae 100644 --- a/gnes/cli/parser.py +++ b/gnes/cli/parser.py @@ -308,6 +308,10 @@ def _set_grpc_parser(parser=None): help='host port of the grpc service') parser.add_argument('--max_message_size', type=int, default=-1, help='maximum send and receive size for grpc server in bytes, -1 means unlimited') + parser.add_argument('--proxy', action=ActionNoYes, default=False, + help='respect the http_proxy and https_proxy environment variables. ' + 'otherwise, it will unset these proxy variables before start. ' + 'gRPC seems perfer --no_proxy') return parser diff --git a/gnes/client/base.py b/gnes/client/base.py index aaaa6862..3d71ef76 100644 --- a/gnes/client/base.py +++ b/gnes/client/base.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from typing import Tuple, List, Union import grpc @@ -120,6 +121,9 @@ class GrpcClient: def __init__(self, args): self.args = args + if not args.proxy: + os.unsetenv('http_proxy') + os.unsetenv('https_proxy') self.logger = set_logger(self.__class__.__name__, self.args.verbose) self.logger.info('setting up grpc insecure channel...') # A gRPC channel provides a connection to a remote gRPC server. diff --git a/gnes/flow/__init__.py b/gnes/flow/__init__.py index cfda7d96..b698ef03 100644 --- a/gnes/flow/__init__.py +++ b/gnes/flow/__init__.py @@ -1,5 +1,4 @@ import copy -import os from collections import OrderedDict, defaultdict from contextlib import ExitStack from functools import wraps @@ -226,8 +225,6 @@ def query(self, bytes_gen: Iterator[bytes] = None, **kwargs): @_build_level(BuildLevel.RUNTIME) def _call_client(self, bytes_gen: Iterator[bytes] = None, **kwargs): - os.unsetenv('http_proxy') - os.unsetenv('https_proxy') args, p_args = self._get_parsed_args(self, set_client_cli_parser, kwargs) p_args.grpc_port = self._service_nodes[self._frontend]['parsed_args'].grpc_port p_args.grpc_host = self._service_nodes[self._frontend]['parsed_args'].grpc_host diff --git a/gnes/service/frontend.py b/gnes/service/frontend.py index 051f5350..909f10f1 100644 --- a/gnes/service/frontend.py +++ b/gnes/service/frontend.py @@ -14,6 +14,7 @@ # limitations under the License. +import os import threading from concurrent.futures import ThreadPoolExecutor @@ -28,6 +29,9 @@ class FrontendService: def __init__(self, args): + if not args.proxy: + os.unsetenv('http_proxy') + os.unsetenv('https_proxy') self.logger = set_logger(self.__class__.__name__, args.verbose) self.server = grpc.server( ThreadPoolExecutor(max_workers=args.max_concurrency),