Browse Source

Add client_id to RPC client

A Gearman client can set a client id which is then used on the server
side to identify the connection. Lack of a client_id makes it harder to
follow the flow when looking at logs:

 gear.Connection.b'unknown'  INFO Connected to 127.0.0.1 port 4730
 gear.Server Accepted connection
  <gear.ServerConnection ... name: None ...>
                                   ^^^^

In RPCClient, introduce a client_id argument which is passed to
gear.Client().
Update callers to set a meaningful client_id.

Change-Id: Idbd63f15b0cde3d77fe969c7650f4eb18aec1ef6
changes/01/704201/2
Antoine Musso 1 year ago
parent
commit
4aca407bd6
4 changed files with 10 additions and 6 deletions
  1. +3
    -2
      zuul/cmd/client.py
  2. +2
    -1
      zuul/lib/fingergw.py
  3. +3
    -2
      zuul/rpcclient.py
  4. +2
    -1
      zuul/web/__init__.py

+ 3
- 2
zuul/cmd/client.py View File

@ -149,7 +149,7 @@ class ZuulRESTClient(object):
class Client(zuul.cmd.ZuulApp):
app_name = 'zuul'
app_description = 'Zuul client.'
app_description = 'Zuul CLI client.'
log = logging.getLogger("zuul.Client")
def createParser(self):
@ -405,7 +405,8 @@ class Client(zuul.cmd.ZuulApp):
ssl_ca = get_default(self.config, 'gearman', 'ssl_ca')
client = zuul.rpcclient.RPCClient(
server, port, ssl_key,
ssl_cert, ssl_ca)
ssl_cert, ssl_ca,
client_id=self.app_description)
elif 'webclient' in conf_sections:
self.log.debug('web section found in config, using REST client')
server = get_default(self.config, 'webclient', 'url', None)


+ 2
- 1
zuul/lib/fingergw.py View File

@ -158,7 +158,8 @@ class FingerGateway(object):
self.gear_port,
self.gear_ssl_key,
self.gear_ssl_cert,
self.gear_ssl_ca)
self.gear_ssl_ca,
client_id='Zuul Finger Gateway')
self.server = streamer_utils.CustomThreadingTCPServer(
self.address,


+ 3
- 2
zuul/rpcclient.py View File

@ -26,9 +26,10 @@ class RPCFailure(Exception):
class RPCClient(object):
log = logging.getLogger("zuul.RPCClient")
def __init__(self, server, port, ssl_key=None, ssl_cert=None, ssl_ca=None):
def __init__(self, server, port, ssl_key=None, ssl_cert=None, ssl_ca=None,
client_id='Zuul RPC Client'):
self.log.debug("Connecting to gearman at %s:%s" % (server, port))
self.gearman = gear.Client()
self.gearman = gear.Client(client_id)
self.gearman.addServer(server, port, ssl_key, ssl_cert, ssl_ca,
keepalive=True, tcp_keepidle=60,
tcp_keepintvl=30, tcp_keepcnt=5)


+ 2
- 1
zuul/web/__init__.py View File

@ -1085,7 +1085,8 @@ class ZuulWeb(object):
self.static_path = os.path.abspath(static_path or STATIC_DIR)
# instanciate handlers
self.rpc = zuul.rpcclient.RPCClient(gear_server, gear_port,
ssl_key, ssl_cert, ssl_ca)
ssl_key, ssl_cert, ssl_ca,
client_id='Zuul Web Server')
self.zk = zuul.zk.ZooKeeper(enable_cache=True)
if zk_hosts:
self.zk.connect(hosts=zk_hosts, read_only=True)


Loading…
Cancel
Save