From bd0ffd4b3a60e9c7b350deecd93e5f573f0fa89c Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Jun 17 2021 08:14:31 +0000 Subject: Bump cephadm to 16.2.4-5 and include monitoring stack patches A new June batch backport is done, including the patches listed in [1]. [1] https://github.com/ceph/ceph/pull/41815 --- diff --git a/SOURCES/cephadm b/SOURCES/cephadm index a7b664c..107f705 100644 --- a/SOURCES/cephadm +++ b/SOURCES/cephadm @@ -279,7 +279,6 @@ class Monitoring(object): 'args': [ '--config.file=/etc/prometheus/prometheus.yml', '--storage.tsdb.path=/prometheus', - '--web.listen-address=:{}'.format(port_map['prometheus'][0]), ], 'config-json-files': [ 'prometheus.yml', @@ -310,7 +309,6 @@ class Monitoring(object): 'cpus': '2', 'memory': '2GB', 'args': [ - '--web.listen-address=:{}'.format(port_map['alertmanager'][0]), '--cluster.listen-address=:{}'.format(port_map['alertmanager'][1]), ], 'config-json-files': [ @@ -1473,6 +1471,16 @@ def call_timeout(ctx, command, timeout): ################################## +def json_loads_retry(cli_func): + for sleep_secs in [1, 4, 4]: + try: + return json.loads(cli_func()) + except json.JSONDecodeError: + logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs) + time.sleep(sleep_secs) + return json.loads(cli_func()) + + def is_available(ctx, what, func): # type: (CephadmContext, str, Callable[[], bool]) -> None """ @@ -2111,6 +2119,17 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id): elif daemon_type in Monitoring.components: metadata = Monitoring.components[daemon_type] r += metadata.get('args', list()) + # set ip and port to bind to for nodeexporter,alertmanager,prometheus + if daemon_type != 'grafana': + ip = '' + port = Monitoring.port_map[daemon_type][0] + if 'meta_json' in ctx and ctx.meta_json: + meta = json.loads(ctx.meta_json) or {} + if 'ip' in meta and meta['ip']: + ip = meta['ip'] + if 'ports' in meta and meta['ports']: + port = meta['ports'][0] + r += [f'--web.listen-address={ip}:{port}'] if daemon_type == 'alertmanager': config = get_parm(ctx.config_json) peers = config.get('peers', list()) # type: ignore @@ -2907,15 +2926,7 @@ class Firewalld(object): def update_firewalld(ctx, daemon_type): # type: (CephadmContext, str) -> None firewall = Firewalld(ctx) - firewall.enable_service_for(daemon_type) - - fw_ports = [] - - if daemon_type in Monitoring.port_map.keys(): - fw_ports.extend(Monitoring.port_map[daemon_type]) # prometheus etc - - firewall.open_ports(fw_ports) firewall.apply_rules() @@ -4009,14 +4020,15 @@ def command_bootstrap(ctx): image_ver = CephContainer(ctx, ctx.image, 'ceph', ['--version']).run().strip() logger.info(f'Ceph version: {image_ver}') - image_release = image_ver.split()[4] - if ( - not ctx.allow_mismatched_release - and image_release not in [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE] - ): - raise Error( - f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE}; please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)' - ) + + if not ctx.allow_mismatched_release: + image_release = image_ver.split()[4] + if image_release not in \ + [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE]: + raise Error( + f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE};' + ' please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)' + ) logger.info('Extracting ceph user uid/gid from container image...') (uid, gid) = extract_uid_gid(ctx) @@ -4089,15 +4101,6 @@ def command_bootstrap(ctx): '-i', '/var/lib/ceph/user.conf'], {tmp.name: '/var/lib/ceph/user.conf:z'}) - def json_loads_retry(cli_func): - for sleep_secs in [1, 4, 4]: - try: - return json.loads(cli_func()) - except json.JSONDecodeError: - logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs) - time.sleep(sleep_secs) - return json.loads(cli_func()) - # wait for mgr to restart (after enabling a module) def wait_for_mgr_restart(): # first get latest mgrmap epoch from the mon. try newer 'mgr @@ -4316,9 +4319,6 @@ def command_deploy(ctx): elif daemon_type in Monitoring.components: # monitoring daemon - prometheus, grafana, alertmanager, node-exporter # Default Checks - if not ctx.reconfig and not redeploy: - daemon_ports.extend(Monitoring.port_map[daemon_type]) - # make sure provided config-json is sufficient config = get_parm(ctx.config_json) # type: ignore required_files = Monitoring.components[daemon_type].get('config-json-files', list()) @@ -8131,18 +8131,15 @@ def _parse_args(av): return args -def cephadm_init_ctx(args: List[str]) -> Optional[CephadmContext]: - +def cephadm_init_ctx(args: List[str]) -> CephadmContext: ctx = CephadmContext() ctx.set_args(_parse_args(args)) return ctx -def cephadm_init(args: List[str]) -> Optional[CephadmContext]: - +def cephadm_init(args: List[str]) -> CephadmContext: global logger ctx = cephadm_init_ctx(args) - assert ctx is not None # Logger configuration if not os.path.exists(LOG_DIR): @@ -8167,10 +8164,6 @@ def cephadm_init(args: List[str]) -> Optional[CephadmContext]: if handler.name == 'console': handler.setLevel(logging.DEBUG) - if not ctx.has_function(): - sys.stderr.write('No command specified; pass -h or --help for usage\n') - return None - return ctx @@ -8185,7 +8178,8 @@ def main(): av = sys.argv[1:] ctx = cephadm_init(av) - if not ctx: # error, exit + if not ctx.has_function(): + sys.stderr.write('No command specified; pass -h or --help for usage\n') sys.exit(1) try: diff --git a/SOURCES/cephadm-16.2.4-5.patch b/SOURCES/cephadm-16.2.4-5.patch new file mode 100644 index 0000000..290199c --- /dev/null +++ b/SOURCES/cephadm-16.2.4-5.patch @@ -0,0 +1,163 @@ +diff --git a/SOURCES/cephadm b/SOURCES/cephadm +index a7b664c..107f705 100644 +--- a/SOURCES/cephadm ++++ b/SOURCES/cephadm +@@ -279,7 +279,6 @@ class Monitoring(object): + 'args': [ + '--config.file=/etc/prometheus/prometheus.yml', + '--storage.tsdb.path=/prometheus', +- '--web.listen-address=:{}'.format(port_map['prometheus'][0]), + ], + 'config-json-files': [ + 'prometheus.yml', +@@ -310,7 +309,6 @@ class Monitoring(object): + 'cpus': '2', + 'memory': '2GB', + 'args': [ +- '--web.listen-address=:{}'.format(port_map['alertmanager'][0]), + '--cluster.listen-address=:{}'.format(port_map['alertmanager'][1]), + ], + 'config-json-files': [ +@@ -1473,6 +1471,16 @@ def call_timeout(ctx, command, timeout): + ################################## + + ++def json_loads_retry(cli_func): ++ for sleep_secs in [1, 4, 4]: ++ try: ++ return json.loads(cli_func()) ++ except json.JSONDecodeError: ++ logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs) ++ time.sleep(sleep_secs) ++ return json.loads(cli_func()) ++ ++ + def is_available(ctx, what, func): + # type: (CephadmContext, str, Callable[[], bool]) -> None + """ +@@ -2111,6 +2119,17 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id): + elif daemon_type in Monitoring.components: + metadata = Monitoring.components[daemon_type] + r += metadata.get('args', list()) ++ # set ip and port to bind to for nodeexporter,alertmanager,prometheus ++ if daemon_type != 'grafana': ++ ip = '' ++ port = Monitoring.port_map[daemon_type][0] ++ if 'meta_json' in ctx and ctx.meta_json: ++ meta = json.loads(ctx.meta_json) or {} ++ if 'ip' in meta and meta['ip']: ++ ip = meta['ip'] ++ if 'ports' in meta and meta['ports']: ++ port = meta['ports'][0] ++ r += [f'--web.listen-address={ip}:{port}'] + if daemon_type == 'alertmanager': + config = get_parm(ctx.config_json) + peers = config.get('peers', list()) # type: ignore +@@ -2907,15 +2926,7 @@ class Firewalld(object): + def update_firewalld(ctx, daemon_type): + # type: (CephadmContext, str) -> None + firewall = Firewalld(ctx) +- + firewall.enable_service_for(daemon_type) +- +- fw_ports = [] +- +- if daemon_type in Monitoring.port_map.keys(): +- fw_ports.extend(Monitoring.port_map[daemon_type]) # prometheus etc +- +- firewall.open_ports(fw_ports) + firewall.apply_rules() + + +@@ -4009,14 +4020,15 @@ def command_bootstrap(ctx): + + image_ver = CephContainer(ctx, ctx.image, 'ceph', ['--version']).run().strip() + logger.info(f'Ceph version: {image_ver}') +- image_release = image_ver.split()[4] +- if ( +- not ctx.allow_mismatched_release +- and image_release not in [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE] +- ): +- raise Error( +- f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE}; please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)' +- ) ++ ++ if not ctx.allow_mismatched_release: ++ image_release = image_ver.split()[4] ++ if image_release not in \ ++ [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE]: ++ raise Error( ++ f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE};' ++ ' please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)' ++ ) + + logger.info('Extracting ceph user uid/gid from container image...') + (uid, gid) = extract_uid_gid(ctx) +@@ -4089,15 +4101,6 @@ def command_bootstrap(ctx): + '-i', '/var/lib/ceph/user.conf'], + {tmp.name: '/var/lib/ceph/user.conf:z'}) + +- def json_loads_retry(cli_func): +- for sleep_secs in [1, 4, 4]: +- try: +- return json.loads(cli_func()) +- except json.JSONDecodeError: +- logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs) +- time.sleep(sleep_secs) +- return json.loads(cli_func()) +- + # wait for mgr to restart (after enabling a module) + def wait_for_mgr_restart(): + # first get latest mgrmap epoch from the mon. try newer 'mgr +@@ -4316,9 +4319,6 @@ def command_deploy(ctx): + elif daemon_type in Monitoring.components: + # monitoring daemon - prometheus, grafana, alertmanager, node-exporter + # Default Checks +- if not ctx.reconfig and not redeploy: +- daemon_ports.extend(Monitoring.port_map[daemon_type]) +- + # make sure provided config-json is sufficient + config = get_parm(ctx.config_json) # type: ignore + required_files = Monitoring.components[daemon_type].get('config-json-files', list()) +@@ -8131,18 +8131,15 @@ def _parse_args(av): + return args + + +-def cephadm_init_ctx(args: List[str]) -> Optional[CephadmContext]: +- ++def cephadm_init_ctx(args: List[str]) -> CephadmContext: + ctx = CephadmContext() + ctx.set_args(_parse_args(args)) + return ctx + + +-def cephadm_init(args: List[str]) -> Optional[CephadmContext]: +- ++def cephadm_init(args: List[str]) -> CephadmContext: + global logger + ctx = cephadm_init_ctx(args) +- assert ctx is not None + + # Logger configuration + if not os.path.exists(LOG_DIR): +@@ -8167,10 +8164,6 @@ def cephadm_init(args: List[str]) -> Optional[CephadmContext]: + if handler.name == 'console': + handler.setLevel(logging.DEBUG) + +- if not ctx.has_function(): +- sys.stderr.write('No command specified; pass -h or --help for usage\n') +- return None +- + return ctx + + +@@ -8185,7 +8178,8 @@ def main(): + av = sys.argv[1:] + + ctx = cephadm_init(av) +- if not ctx: # error, exit ++ if not ctx.has_function(): ++ sys.stderr.write('No command specified; pass -h or --help for usage\n') + sys.exit(1) + + try: diff --git a/SPECS/cephadm.spec.in b/SPECS/cephadm.spec.in index 0c53c9f..5405cab 100644 --- a/SPECS/cephadm.spec.in +++ b/SPECS/cephadm.spec.in @@ -4,11 +4,12 @@ Name: cephadm Epoch: 2 Version: 16.2.4 -Release: 3%{?dist} +Release: 5%{?dist} Summary: Utility to bootstrap Ceph clusters License: LGPL-2.1 URL: https://ceph.io -Source0: https://github.com/ceph/ceph/raw/e132babf2904505731f0d45d5168c7e0e12c06be/src/cephadm/cephadm +#Source0: https://github.com/ceph/ceph/raw/e132babf2904505731f0d45d5168c7e0e12c06be/src/cephadm/cephadm +Source0: https://raw.githubusercontent.com/ceph/ceph/pacific/src/cephadm/cephadm Source1: COPYING-LGPL2.1 BuildArch: noarch @@ -54,6 +55,12 @@ exit 0 %changelog +* Thu Jun 17 2021 Francesco Pantano - 2:16.2.4-5 +- 16.2.4-5 GA + +* Thu Jun 11 2021 Francesco Pantano - 2:16.2.4-4 +- 16.2.4-4 GA + * Thu Jun 10 2021 Francesco Pantano - 2:16.2.4-3 - 16.2.4-3 GA