From 7969b96a8651614d69126bbca812ccf87074863f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Wed, 29 Jan 2020 09:27:42 +0100 Subject: [PATCH] gear: remove support for custom MASS_DO packet Zuul 2.5 Ansible launcher registered ten of thousands of functions on each node which, when done serially, took a while. To alleviate that issue the Gear protocol had been extended with a custom MASS_DO packet to register several functions in a single call (see d437159887). The Ansible launcher has been superseeded by the executor server removing the sole use of MASS_DO. The extended Gear.Server had not been cleaned up though. Replace custom zuul.lib.gearserver.GearServer() with gear.Server() and remove code. For posterity, the MASS_DO idea is captured in Gearman upstream issue tracker: https://github.com/gearman/gearmand/issues/6 Change-Id: Ifc57f9b7a17d1d9291a535eb0d9f5e1da3713241 --- zuul/cmd/scheduler.py | 26 +++++++++++++------------- zuul/lib/gearserver.py | 35 ----------------------------------- 2 files changed, 13 insertions(+), 48 deletions(-) delete mode 100644 zuul/lib/gearserver.py diff --git a/zuul/cmd/scheduler.py b/zuul/cmd/scheduler.py index a2b6a1df57..82a589091a 100755 --- a/zuul/cmd/scheduler.py +++ b/zuul/cmd/scheduler.py @@ -85,7 +85,7 @@ class Scheduler(zuul.cmd.ZuulDaemonApp): if child_pid == 0: os.close(pipe_write) self.setup_logging('gearman_server', 'log_config') - import zuul.lib.gearserver + import gear (statsd_host, statsd_port, statsd_prefix) = get_statsd_config( self.config) @@ -100,18 +100,18 @@ class Scheduler(zuul.cmd.ZuulDaemonApp): ssl_key = get_default(self.config, 'gearman_server', 'ssl_key') ssl_cert = get_default(self.config, 'gearman_server', 'ssl_cert') ssl_ca = get_default(self.config, 'gearman_server', 'ssl_ca') - zuul.lib.gearserver.GearServer(port, - ssl_key=ssl_key, - ssl_cert=ssl_cert, - ssl_ca=ssl_ca, - host=host, - statsd_host=statsd_host, - statsd_port=statsd_port, - statsd_prefix=statsd_prefix, - keepalive=True, - tcp_keepidle=300, - tcp_keepintvl=60, - tcp_keepcnt=5) + gear.Server(port, + ssl_key=ssl_key, + ssl_cert=ssl_cert, + ssl_ca=ssl_ca, + host=host, + statsd_host=statsd_host, + statsd_port=statsd_port, + statsd_prefix=statsd_prefix, + keepalive=True, + tcp_keepidle=300, + tcp_keepintvl=60, + tcp_keepcnt=5) # Keep running until the parent dies: pipe_read = os.fdopen(pipe_read) diff --git a/zuul/lib/gearserver.py b/zuul/lib/gearserver.py deleted file mode 100644 index 9cddca346b..0000000000 --- a/zuul/lib/gearserver.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2016 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import gear - -MASS_DO = 101 - - -class GearServer(gear.Server): - def handlePacket(self, packet): - if packet.ptype == MASS_DO: - self.log.info("Received packet from %s: %s" % (packet.connection, - packet)) - self.handleMassDo(packet) - else: - return super(GearServer, self).handlePacket(packet) - - def handleMassDo(self, packet): - packet.connection.functions = set() - for name in packet.data.split(b'\x00'): - self.log.debug("Adding function %s to %s" % ( - name, packet.connection)) - packet.connection.functions.add(name) - self.functions.add(name)