From 40b70c632d22dbd4cf68f8ad0df1b30ee28b9f19 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 16 Dec 2019 15:46:25 -0600 Subject: [PATCH] cephadm: move mon creation config bits into mgr/cephadm There's no need for mgr/cephadm to pass --mon-* arguments to /usr/bin/cephadm just so it can add bits to the config file when the config file is also being passed in from mgr/cephadm. Signed-off-by: Sage Weil --- qa/workunits/cephadm/test_cephadm.sh | 7 ++++++- src/cephadm/cephadm | 21 --------------------- src/pybind/mgr/cephadm/module.py | 13 ++++++++----- test_cephadm.sh | 20 ++++++++++---------- 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/qa/workunits/cephadm/test_cephadm.sh b/qa/workunits/cephadm/test_cephadm.sh index fed89a25c23c8..7295319b2025e 100755 --- a/qa/workunits/cephadm/test_cephadm.sh +++ b/qa/workunits/cephadm/test_cephadm.sh @@ -110,6 +110,7 @@ $CEPHADM shell --fsid $FSID -- ceph -v | grep 'ceph version' ## bootstrap ORIG_CONFIG=`mktemp -p $TMPDIR` CONFIG=`mktemp -p $TMPDIR` +MONCONFIG=`mktemp -p $TMPDIR` KEYRING=`mktemp -p $TMPDIR` IP=127.0.0.1 cat < $ORIG_CONFIG @@ -153,9 +154,10 @@ $CEPHADM ls | jq '.[]' | jq 'select(.name == "mgr.x").fsid' \ ## deploy # add mon.b +cp $CONFIG $MONCONFIG +echo "public addr = $IP:3301" >> $MONCONFIG $CEPHADM deploy --name mon.b \ --fsid $FSID \ - --mon-ip $IP:3301 \ --keyring /var/lib/ceph/$FSID/mon.a/keyring \ --config $CONFIG for u in ceph-$FSID@mon.b; do @@ -177,6 +179,9 @@ for u in ceph-$FSID@mgr.y; do systemctl is-enabled $u systemctl is-active $u done + +exit 0 + for f in `seq 1 30`; do if $CEPHADM shell --fsid $FSID \ --config $CONFIG --keyring $KEYRING -- \ diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 4f679b176bb71..fabcaf02b0093 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1711,18 +1711,6 @@ def command_deploy(): if daemon_type in Ceph.daemons: (config, keyring, crash_keyring) = get_config_and_both_keyrings() - if daemon_type == 'mon': - if args.mon_ip: - config += '[mon.%s]\n\tpublic_addr = %s\n' % (daemon_id, args.mon_ip) - elif args.mon_addrv: - config += '[mon.%s]\n\tpublic_addrv = %s\n' % (daemon_id, - args.mon_addrv) - elif args.mon_network: - config += '[mon.%s]\n\tpublic_network = %s\n' % (daemon_id, - args.mon_network) - else: - raise Error('must specify --mon-ip or --mon-network') - (uid, gid) = extract_uid_gid() c = get_container(args.fsid, daemon_type, daemon_id) deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid, @@ -2542,15 +2530,6 @@ def _get_parser(): parser_deploy.add_argument( '--config-and-keyrings', help='JSON file with config and keyrings for the daemon and crash agent') - parser_deploy.add_argument( - '--mon-ip', - help='mon IP') - parser_deploy.add_argument( - '--mon-addrv', - help='mon IPs (e.g., [v2:localipaddr:3300,v1:localipaddr:6789])') - parser_deploy.add_argument( - '--mon-network', - help='mon network (CIDR)') parser_deploy.add_argument( '--osd-fsid', help='OSD uuid, if creating an OSD container') diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 964bb45b539a6..a470c9c96dfbb 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1053,13 +1053,15 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): return self._remove_daemon(args) def _create_daemon(self, daemon_type, daemon_id, host, keyring, - extra_args=[]): + extra_args=[], extra_config=None): name = '%s.%s' % (daemon_type, daemon_id) # generate config ret, config, err = self.mon_command({ "prefix": "config generate-minimal-conf", }) + if extra_config: + config += extra_config ret, crash_keyring, err = self.mon_command({ 'prefix': 'auth get-or-create', @@ -1129,17 +1131,18 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): }) # infer whether this is a CIDR network, addrvec, or plain IP + extra_config = '[mon.%s]\n' % name if '/' in network: - extra_args = ['--mon-network', network] + extra_config += 'public network = %s\n' % network elif network.startswith('[v') and network.endswith(']'): - extra_args = ['--mon-addrv', network] + extra_config += 'public addrv = %s\n' % network elif ':' not in network: - extra_args = ['--mon-ip', network] + extra_config += 'public addr = %s\n' % network else: raise RuntimeError('Must specify a CIDR network, ceph addrvec, or plain IP: \'%s\'' % network) return self._create_daemon('mon', name or host, host, keyring, - extra_args=extra_args) + extra_config=extra_config) def update_mons(self, spec): # type: (orchestrator.StatefulServiceSpec) -> orchestrator.Completion diff --git a/test_cephadm.sh b/test_cephadm.sh index ac8763fa89807..a9204fc46b6d8 100755 --- a/test_cephadm.sh +++ b/test_cephadm.sh @@ -43,16 +43,16 @@ $CEPHADM $A \ --allow-overwrite chmod 644 k c -if [ -n "$ip2" ]; then - # mon.b - $CEPHADM $A \ - --image $image \ - deploy --name mon.b \ - --fsid $fsid \ - --mon-addrv "[v2:$ip2:3300,v1:$ip2:6789]" \ - --keyring /var/lib/ceph/$fsid/mon.a/keyring \ - --config c -fi +# mon.b +cp c c.mon +echo "public addrv = [v2:$ip:3301,v1:$ip:6790]" >> c.mon +$CEPHADM $A \ + --image $image \ + deploy --name mon.b \ + --fsid $fsid \ + --keyring /var/lib/ceph/$fsid/mon.a/keyring \ + --config c.mon +rm c.mon # mgr.b bin/ceph -c c -k k auth get-or-create mgr.y \ -- 2.39.5