From 99ab1c0175c2516ea6d7ee46e64ef4e6d3daf10f Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Mon, 20 Jul 2020 15:30:47 +1200 Subject: Remove Trusty support, remove perf The charms.benchmark support and charm has been dead since Trusty, therefore the action for this should be removed entirely along with Trusty support in the charm Fixes-bug: LP:#1526990 --- Makefile | 4 -- README.md | 39 ----------------- actions.yaml | 49 --------------------- actions/perf | 132 --------------------------------------------------------- hooks/hooks.py | 48 +++------------------ metadata.yaml | 3 -- 6 files changed, 7 insertions(+), 268 deletions(-) delete mode 100755 actions/perf diff --git a/Makefile b/Makefile index 2fdc717..fde3fc8 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,5 @@ sync: @curl -o bin/charm_helpers_sync.py https://raw.githubusercontent.com/juju/charm-helpers/master/tools/charm_helpers_sync/charm_helpers_sync.py @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-sync.yaml -# publish: lint unit -# bzr push lp:charms/mongodb -# bzr push lp:charms/trusty/mongodb - # The targets below don't depend on a file .PHONY: lint test unittest functional publish sync diff --git a/README.md b/README.md index 3b3560c..1b8e78e 100644 --- a/README.md +++ b/README.md @@ -236,45 +236,6 @@ disk space. To fetch the backups scp the files down from the path in the config. -### Benchmarking - -Mongo units can be benchmarked via the `perf` juju action, available beginning with juju 1.23. - - $ juju action defined mongodb - perf: The standard mongoperf benchmark. - $ juju action do mongodb/0 perf - Action queued with id: 23532149-15c2-47f0-8d97-115fb7dfa1cd - $ juju action fetch --wait 0 23532149-15c2-47f0-8d97-115fb7dfa1cd - results: - meta: - composite: - direction: desc - units: ops/sec - value: "7736507.70391" - start: 2015-05-07T16:36:04Z - stop: 2015-05-07T16:39:05Z - results: - average: - units: ops/sec - value: "7736507.70391" - iterations: - units: iterations - value: "179" - max: - units: ops/sec - value: "10282496" - min: - units: ops/sec - value: "3874546" - total: - units: ops - value: "1384834879" - status: completed - timing: - completed: 2015-05-07 16:39:06 +0000 UTC - enqueued: 2015-05-07 16:36:01 +0000 UTC - started: 2015-05-07 16:36:04 +0000 UTC - ## Known Limitations and Issues - If your master/slave/replicaset deployment is not updating correctly, check the log files at `/var/log/mongodb/mongodb.log` to see if there is an obvious reason ( port not open etc.). diff --git a/actions.yaml b/actions.yaml index 166cb45..3d53dd1 100644 --- a/actions.yaml +++ b/actions.yaml @@ -1,52 +1,3 @@ -perf: - description: The standard mongoperf benchmark. - params: - runtime: - description: The time, in seconds, to run mongoperf. - type: integer - default: 180 - nthreads: - description: | - Defines the number of threads mongoperf will use in the test. To saturate your system’s storage system you will need multiple threads. Consider setting nThreads to 16. - type: integer - default: 1 - fileSizeMB: - description: Test file size, in megabytes. - type: integer - default: 1 - sleepMicros: - description: | - mongoperf will pause for the number of specified sleepMicros divided by the nThreads between each operation. - type: integer - default: 0 - mmf: - description: | - Set mmf to true to use memory mapped files for the tests. - type: boolean - default: False - r: - description: | - Set r to true to perform reads as part of the tests. - type: boolean - default: False - w: - description: | - Set w to true to perform writes as part of the tests. - type: boolean - default: False - recSizeKB: - description: The size of each write operation, in kilobytes. - type: integer - default: 4 - syncDelay: - description: | - Seconds between disk flushes. mongoperf.syncDelay is similar to --syncdelay for mongod. - - The syncDelay controls how frequently mongoperf performs an asynchronous disk flush of the memory mapped file used for testing. By default, mongod performs this operation every 60 seconds. Use syncDelay to test basic system performance of this type of operation. - - Only use syncDelay in conjunction with mmf set to true. - type: integer - default: 0 dump: description: Runs the mongodump command params: diff --git a/actions/perf b/actions/perf deleted file mode 100755 index 444987a..0000000 --- a/actions/perf +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env python3 -import signal -import subprocess -import os -import json -import re -from tempfile import NamedTemporaryFile - -try: - from distutils.spawn import find_executable -except ImportError: - subprocess.check_call(['apt-get', 'install', '-y', 'python3-distutils']) - from distutils.spawn import find_executable - -try: - from charms.benchmark import Benchmark -except ImportError: - subprocess.check_call(['apt-get', 'install', '-y', 'python3-pip']) - subprocess.check_call(['pip3', 'install', '-U', 'charms.benchmark']) - from charms.benchmark import Benchmark - - -def handler(signum, frame): - raise IOError('Timeout') - - -def action_set(key, val): - action_cmd = ['action-set'] - if isinstance(val, dict): - for k, v in val.items(): - action_set('%s.%s' % (key, k), v) - return - - action_cmd.append('%s=%s' % (key, val)) - subprocess.check_call(action_cmd) - - -def action_get(key): - if find_executable('action-get'): - return subprocess.check_output(['action-get', key]).strip() - return None - - -def main(): - - Benchmark.start() - - """ - mongoperf runs until interupted so we have to use a - signal handler to stop it and gather the results - """ - signal.signal(signal.SIGALRM, handler) - runtime = int(action_get('runtime') or 180) - signal.alarm(runtime) - - js = {} - js['nThreads'] = int(action_get('nthreads')) - js['fileSizeMB'] = int(action_get('fileSizeMB')) - js['sleepMicros'] = int(action_get('sleepMicros')) - js['mmf'] = action_get('mmf').decode() - js['r'] = action_get('r').decode() - js['w'] = action_get('w').decode() - js['recSizeKB'] = int(action_get('recSizeKB')) - js['syncDelay'] = int(action_get('syncDelay')) - - config = NamedTemporaryFile(delete=False) - config.write(json.dumps(js).encode()) - config.close() - config = open(config.name, 'r') - - output = NamedTemporaryFile(delete=False) - - p = None - try: - p = subprocess.Popen( - 'mongoperf', - stdin=config, - stdout=output, - ) - os.waitpid(p.pid, 0) - except subprocess.CalledProcessError as e: - rc = e.returncode - print("Exit with error code %d" % rc) - except IOError: - signal.alarm(0) - os.kill(p.pid, signal.SIGKILL) - finally: - os.unlink(config.name) - - output.close() - output = open(output.name, 'r') - scores = [] - regex = re.compile(r'(\d+)\sops\/sec') - for line in output: - m = regex.match(line) - if m: - scores.append(int(m.group(1))) - - action_set( - "results.total", - {'value': sum(scores), 'units': 'ops'} - ) - - action_set( - "results.iterations", - {'value': len(scores), 'units': 'iterations'} - ) - - action_set( - "results.average", - {'value': sum(scores) / len(scores), 'units': 'ops/sec'} - ) - action_set( - "results.max", - {'value': max(scores), 'units': 'ops/sec'} - ) - action_set( - "results.min", - {'value': min(scores), 'units': 'ops/sec'} - ) - - Benchmark.set_composite_score( - sum(scores) / len(scores), - 'ops/sec', - 'desc' - ) - - Benchmark.finish() - - -if __name__ == "__main__": - main() diff --git a/hooks/hooks.py b/hooks/hooks.py index fab26b9..275a0ba 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -19,19 +19,19 @@ import sys import time try: - import distro # flake8: noqa + import distro except ImportError: pip.main(['install', "distro"]) - import distro # flake8: noqa + import distro try: - import yaml # flake8: noqa + import yaml except ImportError: if sys.version_info.major == 2: subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml']) else: subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml']) - import yaml # flake8: noqa + import yaml from os import chmod from os import remove @@ -275,7 +275,7 @@ class TimeoutException(Exception): ############################################################################### # Charm support functions ############################################################################### -def mongodb_conf(config_data=None): # noqa: C901 is too complex (28) +def mongodb_conf(config_data=None): # noqa: C901 if config_data is None: return(None) config = [] @@ -950,19 +950,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin """ % (cron_runtime, script_filename)) -# We can remove this quirk when charm no longer supports trusty -def arm64_trusty_quirk(): - arch = subprocess.check_output(['dpkg', '--print-architecture']).decode("utf8").strip() - if arch != 'arm64': - return - if lsb_release()['DISTRIB_CODENAME'] != 'trusty': - return - ppa = 'ppa:mongodb-arm64/ppa' - juju_log("*** Detected trusty/arm64. Archive version contains incomplete " - "mongodb port, enabling installs from %s ***" % (ppa)) - add_source(ppa) - - ############################################################################### # Hook functions ############################################################################### @@ -974,16 +961,12 @@ def install_hook(): juju_log("Installing mongodb") add_source(config('source'), config('key')) - # Allow users to bypass arm64/trusty workaround by adding their own source - if config('source') == 'None': - arm64_trusty_quirk() - apt_update(fatal=True) apt_install(packages=INSTALL_PACKAGES, fatal=True) -@hooks.hook('config-changed') -def config_changed(): # noqa: C901 is too complex (17) +@hooks.hook('config-changed') # noqa: C901 +def config_changed(): juju_log("Entering config_changed") status_set('maintenance', 'Configuring unit') config_data = config() @@ -1131,23 +1114,6 @@ def stop_hook(): return(retVal) -@hooks.hook('benchmark-relation-joined') -@hooks.hook('benchmark-relation-changed') -def benchmark_relation_joined(): - juju_log('benchmark-relation-joined') - try: - from charms.benchmark import Benchmark - except ImportError: - apt_install('python3-pip', fatal=True) - import subprocess - subprocess.check_call(['pip3', 'install', '-U', 'charms.benchmark']) - from charms.benchmark import Benchmark - - # Send a list of benchmark-enabled actions for display in the benchmark-gui - benchmarks = ['perf'] - Benchmark(benchmarks) - - @hooks.hook('database-relation-joined') def database_relation_joined(): juju_log("database_relation_joined") diff --git a/metadata.yaml b/metadata.yaml index 7992cec..4604c93 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -21,7 +21,6 @@ series: - focal - bionic - xenial - - trusty provides: nrpe-external-master: interface: nrpe-external-master @@ -34,8 +33,6 @@ provides: interface: block-storage scope: container optional: true - benchmark: - interface: benchmark requires: mongos-cfg: interface: shard -- cgit v1.2.3