diff --git a/docs/Configuration.md b/docs/Configuration.md index c80643f7..8c7a533a 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -158,6 +158,7 @@ backup_grace_period_in_days = 10 ; Set to true when running in grpc server mode. ; Allows to propagate the exceptions instead of exiting the program. ;enabled = False +;port = [kubernetes] ; The following settings are only intended to be configured if Medusa is running in containers, preferably in Kubernetes. diff --git a/medusa/config.py b/medusa/config.py index 5355fe4b..3e9d3ddd 100644 --- a/medusa/config.py +++ b/medusa/config.py @@ -73,7 +73,7 @@ GrpcConfig = collections.namedtuple( 'GrpcConfig', - ['enabled', 'max_send_message_length', 'max_receive_message_length'] + ['enabled', 'max_send_message_length', 'max_receive_message_length', 'port'] ) KubernetesConfig = collections.namedtuple( @@ -93,6 +93,7 @@ } DEFAULT_CONFIGURATION_PATH = pathlib.Path('/etc/medusa/medusa.ini') +DEFAULT_GRPC_PORT = 50051 def _build_default_config(): @@ -167,6 +168,7 @@ def _build_default_config(): 'enabled': 'False', 'max_send_message_length': '536870912', 'max_receive_message_length': '134217728', + 'port': f'{DEFAULT_GRPC_PORT}' } config['kubernetes'] = { diff --git a/medusa/service/grpc/server.py b/medusa/service/grpc/server.py index 86b5a5ac..7bb4198a 100644 --- a/medusa/service/grpc/server.py +++ b/medusa/service/grpc/server.py @@ -70,8 +70,9 @@ async def serve(self): medusa_pb2_grpc.add_MedusaServicer_to_server(MedusaService(config), self.grpc_server) health_pb2_grpc.add_HealthServicer_to_server(grpc_health.v1.health.HealthServicer(), self.grpc_server) - logging.info('Starting server. Listening on port 50051.') - self.grpc_server.add_insecure_port('[::]:50051') + grpc_port = int(self.medusa_config.grpc.port) + logging.info(f"Starting server. Listening on port {grpc_port}.") + self.grpc_server.add_insecure_port(f"[::]:{grpc_port}") await self.grpc_server.start() if not self.testing: diff --git a/tests/integration/features/steps/integration_steps.py b/tests/integration/features/steps/integration_steps.py index 77cf6342..01f8806b 100644 --- a/tests/integration/features/steps/integration_steps.py +++ b/tests/integration/features/steps/integration_steps.py @@ -447,7 +447,7 @@ def i_am_using_storage_provider_with_grpc_server(context, storage_provider, clie context.client_encryption = client_encryption context.grpc_server = GRPCServer(config) context.grpc_client = medusa.service.grpc.client.Client( - "127.0.0.1:50051", + f"127.0.0.1:{config['grpc']['port']}", channel_options=[('grpc.enable_retries', 0)] ) @@ -496,7 +496,7 @@ def i_am_using_storage_provider_with_grpc_server_and_mgmt_api(context, storage_p context.client_encryption = client_encryption context.grpc_server = GRPCServer(config) context.grpc_client = medusa.service.grpc.client.Client( - "127.0.0.1:50051", + f"127.0.0.1:{config['grpc']['port']}", channel_options=[('grpc.enable_retries', 0)] )