Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephadm/services/cephadmservice: shutdown monitors before removing them #45511

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 25 additions & 23 deletions qa/tasks/cephadm_cases/test_cli_mon.py
@@ -1,14 +1,14 @@
import json
import logging

import time
from tasks.mgr.mgr_test_case import MgrTestCase

log = logging.getLogger(__name__)


class TestCephadmCLI(MgrTestCase):

APPLY_MON_PERIOD = 60
APPLY_MON_PERIOD = 60 # Shouldn't be this long, but just incase.

def _cmd(self, *args) -> str:
assert self.mgr_cluster is not None
Expand All @@ -20,13 +20,6 @@ def _orch_cmd(self, *args) -> str:
def setUp(self):
super(TestCephadmCLI, self).setUp()

def _create_and_write_pool(self, pool_name):
# Create new pool and write to it, simulating a small workload.
self.mgr_cluster.mon_manager.create_pool(pool_name)
args = [
"rados", "-p", pool_name, "bench", "30", "write", "-t", "16"]
self.mgr_cluster.admin_remote.run(args=args, wait=True)

def _get_quorum_size(self) -> int:
# Evaluate if the quorum size of the cluster is correct.
# log the quorum_status before reducing the monitors
Expand All @@ -43,29 +36,38 @@ def _check_no_crashes(self):
)
log.info("test_apply_mon._check_no_crashes: %s" % retstr)
self.assertEqual(0, len(retstr)) # check if there are no crashes

def _apply_mon_write_pool_and_check(self, num, pool_name):
# Increase/Decrease the monitors to <num> by exercising the orch apply mon command.
# Write to <pool_name> simulate real workloads during apply command.
# Check for crashes and unhealthy cluster states.

def test_apply_mon_three(self):
# Evaluating the process of reducing the number of
# monitors from 5 to 3 and increasing the number of
# monitors from 3 to 5, using the `ceph orch apply mon <num>` command.
self._orch_cmd('apply', 'mon', str(num))

self.wait_until_equal(lambda : self._get_quorum_size(), 5,
timeout=self.APPLY_MON_PERIOD, period=10)

self._orch_cmd('apply', 'mon', '3') # reduce the monitors from 5 -> 3
args = ["rados", "-p", pool_name, "bench", "60", "write", "-t", "16"]

self._create_and_write_pool('test_pool1')
self.mgr_cluster.admin_remote.run(args=args, wait=True) # Write to pool.

self.wait_until_equal(lambda : self._get_quorum_size(), 3,
self.wait_until_equal(lambda : self._get_quorum_size(), num,
timeout=self.APPLY_MON_PERIOD, period=10)

self._check_no_crashes()
self._check_no_crashes() # Check for any crashes.

time.sleep(60) # Buffer for fairness, incase any unhealthy status needed time to appear.

self._orch_cmd('apply', 'mon', '5') # increase the monitors from 3 -> 5
self.wait_for_health_clear(120) # Make sure there is no unhealthy state, e.g., Stray Daemon

self._create_and_write_pool('test_pool2')
def test_decrease_increase_mon(self):
# Evaluating the process of reducing the number of
# monitors from 5 to 3 and increasing the number of
# monitors from 3 to 5, using the `ceph orch apply mon <num>` command.

# Make sure we have 5 MONs at the beginning.
self.wait_until_equal(lambda : self._get_quorum_size(), 5,
timeout=self.APPLY_MON_PERIOD, period=10)

self._check_no_crashes()
# Create 1 pool to be used as part of the test.
self.mgr_cluster.mon_manager.create_pool("test_pool1")

self._apply_mon_write_pool_and_check(3, "test_pool1") # Reduce MON and check.
self._apply_mon_write_pool_and_check(5, "test_pool1") # Increase MON and check.
24 changes: 24 additions & 0 deletions src/cephadm/cephadm.py
Expand Up @@ -7091,6 +7091,7 @@ def _stop_and_disable(ctx, unit_name):
##################################


@infer_config
def command_rm_daemon(ctx):
# type: (CephadmContext) -> None
lock = FileLock(ctx, ctx.fsid)
Expand All @@ -7105,6 +7106,29 @@ def command_rm_daemon(ctx):

call(ctx, ['systemctl', 'stop', unit_name],
verbosity=CallVerbosity.DEBUG)

# remove the mon from cluster after we stop the mon.
# necessary to do this strictly inorder here because
# in the monitor elector code (and possible other parts)
# it is assumed that monitor will be unreachable (stopped)
# before it is removed. This is the correct procedure according to:
# https://docs.ceph.com/en/latest/rados/operations/add-or-rm-mons/#removing-a-monitor-manual
if daemon_type == 'mon':
mon_key_path = os.path.join(get_data_dir(ctx.fsid, ctx.data_dir, 'mon', daemon_id), 'keyring')
c = CephContainer(
ctx,
image=ctx.image,
entrypoint='/usr/bin/ceph',
args=['--name', 'mon.', 'mon', 'remove', daemon_id],
volume_mounts={
mon_key_path: '/etc/ceph/ceph.keyring:z',
ctx.config: '/etc/ceph/ceph.conf:z',
},
)
_, err, ret = call_throws(ctx, c.run_cmd(), timeout=ctx.timeout if ctx.timeout else 60)
if ret:
raise Error(f'Failed removing monitor: {err}')

call(ctx, ['systemctl', 'reset-failed', unit_name],
verbosity=CallVerbosity.DEBUG)
call(ctx, ['systemctl', 'disable', unit_name],
Expand Down
7 changes: 0 additions & 7 deletions src/pybind/mgr/cephadm/services/cephadmservice.py
Expand Up @@ -624,13 +624,6 @@ def pre_remove(self, daemon: DaemonDescription) -> None:
daemon_id: str = daemon.daemon_id
self._check_safe_to_destroy(daemon_id)

# remove mon from quorum before we destroy the daemon
logger.info('Removing monitor %s from monmap...' % daemon_id)
ret, out, err = self.mgr.check_mon_command({
'prefix': 'mon rm',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still getting health warnings whenever I scale down mons at all with this patch.

[ceph: root@vm-00 /]# ceph orch ls 
NAME                       PORTS        RUNNING  REFRESHED  AGE  PLACEMENT  
alertmanager               ?:9093,9094      1/1  47s ago    6m   count:1    
crash                                       3/3  49s ago    6m   *          
grafana                    ?:3000           1/1  47s ago    6m   count:1    
mgr                                         2/2  49s ago    7m   count:2    
mon                                         3/5  49s ago    7m   count:5    
node-exporter              ?:9100           3/3  49s ago    6m   *          
osd.all-available-devices                    12  49s ago    4m   *          
prometheus                 ?:9095           1/1  49s ago    6m   count:1    
[ceph: root@vm-00 /]# ceph orch ps
NAME                 HOST   PORTS        STATUS          REFRESHED   AGE  MEM USE  MEM LIM  VERSION                 IMAGE ID      CONTAINER ID  
alertmanager.vm-00   vm-00  *:9093,9094  running (70s)     51s ago    6m    15.9M        -                          ba2b418f427c  9f6e62f1c9d1  
crash.vm-00          vm-00               running (6m)      51s ago    6m    6979k        -  17.0.0-13734-g96abb011  f4b280ba1496  966c1dfc7d74  
crash.vm-01          vm-01               running (4m)      53s ago    4m    7159k        -  17.0.0-13734-g96abb011  f4b280ba1496  c6b54137989f  
crash.vm-02          vm-02               running (4m)      53s ago    4m    7180k        -  17.0.0-13734-g96abb011  f4b280ba1496  b9d9d21e028e  
grafana.vm-00        vm-00  *:3000       running (66s)     51s ago    6m    40.8M        -  8.3.5                   dad864ee21e9  3b91c5d4cc78  
mgr.vm-00.bdwsut     vm-00  *:9283       running (7m)      51s ago    7m     479M        -  17.0.0-13734-g96abb011  f4b280ba1496  06aec7958775  
mgr.vm-02.haworo     vm-02  *:8443,9283  running (4m)      53s ago    4m     428M        -  17.0.0-13734-g96abb011  f4b280ba1496  5fd8cceb7c0d  
mon.vm-00            vm-00               running (7m)      51s ago    7m    56.5M    2048M  17.0.0-13734-g96abb011  f4b280ba1496  7d09db9b0721  
mon.vm-01            vm-01               running (4m)      53s ago    4m    48.0M    2048M  17.0.0-13734-g96abb011  f4b280ba1496  ea18ee80f985  
mon.vm-02            vm-02               running (4m)      53s ago    4m    52.6M    2048M  17.0.0-13734-g96abb011  f4b280ba1496  30934b1e44e1  
node-exporter.vm-00  vm-00  *:9100       running (6m)      51s ago    6m    19.5M        -                          1dbe0e931976  ebdb46f6cffe  
node-exporter.vm-01  vm-01  *:9100       running (4m)      53s ago    4m    24.0M        -                          1dbe0e931976  2bc17a3379c4  
node-exporter.vm-02  vm-02  *:9100       running (4m)      53s ago    4m    22.8M        -                          1dbe0e931976  1838354f8634  
osd.0                vm-01               running (3m)      53s ago    3m    71.6M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  45d1ec388ca2  
osd.1                vm-02               running (3m)      53s ago    3m    71.9M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  e8829f51624e  
osd.2                vm-00               running (2m)      51s ago    2m    68.1M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  6340cd1be0d5  
osd.3                vm-01               running (2m)      53s ago    2m    70.8M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  ad77363d8a7f  
osd.4                vm-02               running (2m)      53s ago    2m    68.7M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  9219b47952b9  
osd.5                vm-00               running (2m)      51s ago    2m    70.2M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  14d5661c5bab  
osd.6                vm-02               running (110s)    53s ago    2m    68.0M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  427652c89872  
osd.7                vm-02               running (88s)     53s ago  100s    69.0M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  f41b405ce4ca  
osd.8                vm-01               running (2m)      53s ago    2m    68.0M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  3662aca0f34a  
osd.9                vm-00               running (2m)      51s ago    2m    67.4M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  a3c94dc82ebf  
osd.10               vm-01               running (2m)      53s ago    2m    67.2M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  30a0e569b975  
osd.11               vm-00               running (3m)      51s ago    3m    72.0M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  fc1ab3e586c3  
prometheus.vm-01     vm-01  *:9095       running (4m)      53s ago    4m    59.5M        -                          514e6a882f6e  640fcf0a4ee7  
[ceph: root@vm-00 /]# ceph health detail
HEALTH_OK
[ceph: root@vm-00 /]# ceph orch apply mon 2
Scheduled mon update...
[ceph: root@vm-00 /]# ceph orch ls
NAME                       PORTS        RUNNING  REFRESHED  AGE   PLACEMENT  
alertmanager               ?:9093,9094      1/1  97s ago    9m    count:1    
crash                                       3/3  97s ago    9m    *          
grafana                    ?:3000           1/1  97s ago    9m    count:1    
mgr                                         2/2  97s ago    9m    count:2    
mon                                         2/2  97s ago    103s  count:2    
node-exporter              ?:9100           3/3  97s ago    9m    *          
osd.all-available-devices                    12  97s ago    7m    *          
prometheus                 ?:9095           1/1  32s ago    9m    count:1    
[ceph: root@vm-00 /]# ceph orch ps
NAME                 HOST   PORTS        STATUS        REFRESHED  AGE  MEM USE  MEM LIM  VERSION                 IMAGE ID      CONTAINER ID  
alertmanager.vm-00   vm-00  *:9093,9094  running (2m)     9s ago   7m    23.1M        -                          ba2b418f427c  9f6e62f1c9d1  
crash.vm-00          vm-00               running (7m)     9s ago   7m    6979k        -  17.0.0-13734-g96abb011  f4b280ba1496  966c1dfc7d74  
crash.vm-01          vm-01               running (5m)    11s ago   5m    7159k        -  17.0.0-13734-g96abb011  f4b280ba1496  c6b54137989f  
crash.vm-02          vm-02               running (5m)    11s ago   5m    7180k        -  17.0.0-13734-g96abb011  f4b280ba1496  b9d9d21e028e  
grafana.vm-00        vm-00  *:3000       running (2m)     9s ago   7m    44.9M        -  8.3.5                   dad864ee21e9  3b91c5d4cc78  
mgr.vm-00.bdwsut     vm-00  *:9283       running (8m)     9s ago   8m     487M        -  17.0.0-13734-g96abb011  f4b280ba1496  06aec7958775  
mgr.vm-02.haworo     vm-02  *:8443,9283  running (5m)    11s ago   5m     428M        -  17.0.0-13734-g96abb011  f4b280ba1496  5fd8cceb7c0d  
mon.vm-00            vm-00               running (8m)     9s ago   8m    59.7M    2048M  17.0.0-13734-g96abb011  f4b280ba1496  7d09db9b0721  
mon.vm-01            vm-01               running (5m)    11s ago   5m    50.7M    2048M  17.0.0-13734-g96abb011  f4b280ba1496  ea18ee80f985  
node-exporter.vm-00  vm-00  *:9100       running (7m)     9s ago   7m    19.6M        -                          1dbe0e931976  ebdb46f6cffe  
node-exporter.vm-01  vm-01  *:9100       running (5m)    11s ago   5m    21.4M        -                          1dbe0e931976  2bc17a3379c4  
node-exporter.vm-02  vm-02  *:9100       running (5m)    11s ago   5m    24.5M        -                          1dbe0e931976  1838354f8634  
osd.0                vm-01               running (4m)    11s ago   4m    72.9M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  45d1ec388ca2  
osd.1                vm-02               running (4m)    11s ago   4m    73.2M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  e8829f51624e  
osd.2                vm-00               running (3m)     9s ago   3m    69.0M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  6340cd1be0d5  
osd.3                vm-01               running (3m)    11s ago   3m    71.7M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  ad77363d8a7f  
osd.4                vm-02               running (3m)    11s ago   3m    69.8M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  9219b47952b9  
osd.5                vm-00               running (3m)     9s ago   3m    71.1M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  14d5661c5bab  
osd.6                vm-02               running (2m)    11s ago   3m    68.9M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  427652c89872  
osd.7                vm-02               running (2m)    11s ago   2m    70.0M    5435M  17.0.0-13734-g96abb011  f4b280ba1496  f41b405ce4ca  
osd.8                vm-01               running (3m)    11s ago   3m    69.0M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  3662aca0f34a  
osd.9                vm-00               running (3m)     9s ago   3m    68.4M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  a3c94dc82ebf  
osd.10               vm-01               running (3m)    11s ago   3m    68.5M    6203M  17.0.0-13734-g96abb011  f4b280ba1496  30a0e569b975  
osd.11               vm-00               running (4m)     9s ago   4m    73.4M    4923M  17.0.0-13734-g96abb011  f4b280ba1496  fc1ab3e586c3  
prometheus.vm-01     vm-01  *:9095       running (5m)    11s ago   5m    64.2M        -                          514e6a882f6e  640fcf0a4ee7  
[ceph: root@vm-00 /]# ceph health detail
HEALTH_WARN 1/3 mons down, quorum vm-00,vm-01
[WRN] MON_DOWN: 1/3 mons down, quorum vm-00,vm-01
    mon.vm-02 (rank 1) addr [v2:192.168.122.121:3300/0,v1:192.168.122.121:6789/0] is down (out of quorum)

@kamoltat is it just me getting this? When you scale down you don't get any warning?

'name': daemon_id,
})

def post_remove(self, daemon: DaemonDescription, is_failed_deploy: bool) -> None:
# Do not remove the mon keyring.
# super().post_remove(daemon)
Expand Down