Ema has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/328180 )
Change subject: varnish: remove varnishprocessor ...................................................................... varnish: remove varnishprocessor The two scripts depending on varnishprocessor, namely varnishrls and varnishmedia, have been ported to cachestats.CacheStatsSender. Remove varnishprocessor. Bug: T151643 Change-Id: Ifd60651d925467dd01ba21bff8f79c5444bb35bb --- D modules/varnish/files/varnishprocessor/__init__.py D modules/varnish/files/varnishprocessor/varnishprocessor.py M modules/varnish/manifests/common.pp 3 files changed, 1 insertion(+), 120 deletions(-) Approvals: Ema: Verified; Looks good to me, approved diff --git a/modules/varnish/files/varnishprocessor/__init__.py b/modules/varnish/files/varnishprocessor/__init__.py deleted file mode 100644 index c73bf42..0000000 --- a/modules/varnish/files/varnishprocessor/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .varnishprocessor import VarnishLogProcessor # noqa diff --git a/modules/varnish/files/varnishprocessor/varnishprocessor.py b/modules/varnish/files/varnishprocessor/varnishprocessor.py deleted file mode 100644 index e286093..0000000 --- a/modules/varnish/files/varnishprocessor/varnishprocessor.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- -""" - VarnishLogProcessor - ~~~~~~~~~~~~~~~~~~~ - - Processes Varnish log data and sends the output to statsd - - Copyright 2015 Ori Livneh <[email protected]> - Copyright 2015 Gilles Dubuc <[email protected]> - - 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 argparse -import io -import socket -import urlparse - - -class VarnishLogProcessor: - description = 'Varnish Log Processor' - key_prefix = None - statsd_server = None - - def __init__(self): - ap = argparse.ArgumentParser( - description=self.description, - epilog='If no statsd server is specified, prints stats to stdout.' - ) - - print self.key_prefix - - ap.add_argument('--key-prefix', help='metric key prefix', - type=parse_prefix_string, default=self.key_prefix) - ap.add_argument('--statsd-server', help='statsd server', - type=parse_statsd_server_string, default=None) - args = ap.parse_args() - - if args.key_prefix is not None: - self.key_prefix = args.key_prefix - - if args.statsd_server is not None: - self.statsd_server = args.statsd_server - - if self.statsd_server: - self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - - self.stats = {} - self.transactions = {} - - self.start() - - def handle_log_record(self, transaction_id, tag, record, remote_party): - """VSL_handler_f callback function.""" - - if tag == 'ReqURL': - # RxURL is the first tag we expect. If there are any existing - # records for this transaction ID, we clear them away. - self.transactions[transaction_id] = {tag: record} - elif tag == 'Timestamp' and 'Resp' in record: - # This is the last tag we expect. We pop the transaction's records - # from the buffer and process it. - transaction = self.transactions.pop(transaction_id, None) - if transaction is not None: - transaction[tag] = record - self.process_transaction(transaction) - else: - # All other tags are buffered. - transaction = self.transactions.get(transaction_id) - if transaction is not None: - transaction[tag] = record - return 0 - - def flush_stats(self): - """Flush metrics to standard out or statsd server.""" - buf = io.BytesIO() - while self.stats: - key, value = self.stats.popitem() - metric = '%s.%s:%s|c\n' % (self.key_prefix, key, value) - buf.write(metric.encode('utf-8')) - buf.seek(io.SEEK_SET) - if self.statsd_server: - self.sock.sendto(buf.read(), self.statsd_server) - else: - print(buf.read().decode('utf-8').rstrip()) - - def process_transaction(self, transaction): - pass - - def start(): - pass - - -def parse_statsd_server_string(server_string): - parsed = urlparse.urlparse('//' + server_string) - return parsed.hostname, parsed.port or 8125 - - -def parse_prefix_string(prefix): - print prefix - - prefix = prefix.strip('.') - if not prefix: - raise ValueError('Key prefix must not be empty') - return prefix diff --git a/modules/varnish/manifests/common.pp b/modules/varnish/manifests/common.pp index bdf6745..d3130c7 100644 --- a/modules/varnish/manifests/common.pp +++ b/modules/varnish/manifests/common.pp @@ -68,10 +68,7 @@ } file { '/usr/local/lib/python2.7/dist-packages/varnishprocessor': - source => 'puppet:///modules/varnish/varnishprocessor', - owner => 'root', - group => 'root', - mode => '0755', + ensure => absent, recurse => true, purge => true, force => true, -- To view, visit https://gerrit.wikimedia.org/r/328180 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifd60651d925467dd01ba21bff8f79c5444bb35bb Gerrit-PatchSet: 3 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ema <[email protected]> Gerrit-Reviewer: BBlack <[email protected]> Gerrit-Reviewer: Ema <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
