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: