[Notes] [Git][BuildGrid/buildgrid][mablanch/138-exit-on-startup-failure] 5 commits: setup.py: Unpin Sphinx and require RTD theme >= 0.4.2



Title: GitLab

Martin Blanchard pushed to branch mablanch/138-exit-on-startup-failure at BuildGrid / buildgrid

Commits:

4 changed files:

Changes:

  • buildgrid/_app/commands/cmd_server.py
    ... ... @@ -24,6 +24,7 @@ import sys
    24 24
     
    
    25 25
     import click
    
    26 26
     
    
    27
    +from buildgrid._exceptions import PermissionDeniedError
    
    27 28
     from buildgrid.server._authentication import AuthMetadataMethod, AuthMetadataAlgorithm
    
    28 29
     from buildgrid.server.instance import BuildGridServer
    
    29 30
     from buildgrid.server._monitoring import MonitoringOutputType, MonitoringOutputFormat
    
    ... ... @@ -120,8 +121,13 @@ def _create_server_from_config(configuration):
    120 121
     
    
    121 122
         server = BuildGridServer(**kargs)
    
    122 123
     
    
    123
    -    for channel in network:
    
    124
    -        server.add_port(channel.address, channel.credentials)
    
    124
    +    try:
    
    125
    +        for channel in network:
    
    126
    +            server.add_port(channel.address, channel.credentials)
    
    127
    +
    
    128
    +    except PermissionDeniedError as e:
    
    129
    +        click.echo("Error: {}.".format(e), err=True)
    
    130
    +        sys.exit(-1)
    
    125 131
     
    
    126 132
         for instance in instances:
    
    127 133
             instance_name = instance['name']
    

  • buildgrid/_exceptions.py
    ... ... @@ -89,3 +89,9 @@ class FailedPreconditionError(BgdError):
    89 89
         able to fix the errors and retry."""
    
    90 90
         def __init__(self, message, detail=None, reason=None):
    
    91 91
             super().__init__(message, detail=detail, domain=ErrorDomain.SERVER, reason=reason)
    
    92
    +
    
    93
    +
    
    94
    +class PermissionDeniedError(BgdError):
    
    95
    +    """The caller does not have permission to execute the specified operation."""
    
    96
    +    def __init__(self, message, detail=None, reason=None):
    
    97
    +        super().__init__(message, detail=detail, domain=ErrorDomain.SERVER, reason=reason)

  • buildgrid/server/instance.py
    ... ... @@ -27,6 +27,7 @@ import grpc
    27 27
     import janus
    
    28 28
     
    
    29 29
     from buildgrid._enums import BotStatus, LogRecordLevel, MetricRecordDomain, MetricRecordType
    
    30
    +from buildgrid._exceptions import PermissionDeniedError
    
    30 31
     from buildgrid._protos.buildgrid.v2 import monitoring_pb2
    
    31 32
     from buildgrid.server.actioncache.service import ActionCacheService
    
    32 33
     from buildgrid.server._authentication import AuthMetadataMethod, AuthMetadataAlgorithm
    
    ... ... @@ -87,7 +88,8 @@ class BuildGridServer:
    87 88
                 AuthContext.interceptor = self.__grpc_auth_interceptor
    
    88 89
     
    
    89 90
             self.__grpc_executor = futures.ThreadPoolExecutor(max_workers)
    
    90
    -        self.__grpc_server = grpc.server(self.__grpc_executor)
    
    91
    +        self.__grpc_server = grpc.server(self.__grpc_executor,
    
    92
    +                                         options=(('grpc.so_reuseport', 0),))
    
    91 93
     
    
    92 94
             self.__main_loop = asyncio.get_event_loop()
    
    93 95
     
    
    ... ... @@ -205,6 +207,9 @@ class BuildGridServer:
    205 207
     
    
    206 208
             Returns:
    
    207 209
                 int: Number of the bound port.
    
    210
    +
    
    211
    +        Raises:
    
    212
    +            PermissionDeniedError: If socket binding fails.
    
    208 213
             """
    
    209 214
             if credentials is not None:
    
    210 215
                 self.__logger.info("Adding secure connection on: [%s]", address)
    
    ... ... @@ -214,6 +219,9 @@ class BuildGridServer:
    214 219
                 self.__logger.info("Adding insecure connection on [%s]", address)
    
    215 220
                 port_number = self.__grpc_server.add_insecure_port(address)
    
    216 221
     
    
    222
    +        if not port_number:
    
    223
    +            raise PermissionDeniedError("Unable to configure socket")
    
    224
    +
    
    217 225
             return port_number
    
    218 226
     
    
    219 227
         def add_execution_instance(self, instance, instance_name):
    

  • setup.py
    ... ... @@ -102,10 +102,9 @@ tests_require = [
    102 102
     ]
    
    103 103
     
    
    104 104
     docs_require = [
    
    105
    -    # rtd-theme broken in Sphinx >= 1.8, this breaks search functionality.
    
    106
    -    'sphinx == 1.7.8',
    
    105
    +    'sphinx',
    
    107 106
         'sphinx-click',
    
    108
    -    'sphinx-rtd-theme',
    
    107
    +    'sphinx-rtd-theme >= 0.4.2',  # For HTML search fix (upstream #672)
    
    109 108
         'sphinxcontrib-apidoc',
    
    110 109
         'sphinxcontrib-napoleon',
    
    111 110
     ]
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]