예제 #1
0
    def test_daemon_action_fail(self, cephadm_module: CephadmOrchestrator):
        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            with with_daemon(cephadm_module,
                             RGWSpec(service_id='myrgw.foobar'),
                             CephadmOrchestrator.add_rgw, 'test') as daemon_id:
                with mock.patch('ceph_module.BaseMgrModule._ceph_send_command'
                                ) as _ceph_send_command:

                    _ceph_send_command.side_effect = Exception("myerror")

                    # Make sure, _check_daemons does a redeploy due to monmap change:
                    cephadm_module.mock_store_set(
                        '_ceph_get', 'mon_map', {
                            'modified':
                            datetime.datetime.utcnow().strftime(CEPH_DATEFMT),
                            'fsid':
                            'foobar',
                        })
                    cephadm_module.notify('mon_map', None)

                    cephadm_module._check_daemons()

                    evs = [
                        e.message
                        for e in cephadm_module.events.get_for_daemon(
                            f'rgw.{daemon_id}')
                    ]

                    assert 'myerror' in ''.join(evs)
예제 #2
0
    def test_daemon_check_post(self, cephadm_module: CephadmOrchestrator):
        with with_host(cephadm_module, 'test'):
            with with_service(cephadm_module,
                              ServiceSpec(service_type='grafana'),
                              CephadmOrchestrator.apply_grafana, 'test'):

                # Make sure, _check_daemons does a redeploy due to monmap change:
                cephadm_module.mock_store_set(
                    '_ceph_get', 'mon_map', {
                        'modified':
                        datetime.datetime.utcnow().strftime(CEPH_DATEFMT),
                        'fsid':
                        'foobar',
                    })
                cephadm_module.notify('mon_map', None)
                cephadm_module.mock_store_set('_ceph_get', 'mgr_map',
                                              {'modules': ['dashboard']})

                with mock.patch(
                        "cephadm.module.CephadmOrchestrator.mon_command"
                ) as _mon_cmd:

                    cephadm_module._check_daemons()
                    _mon_cmd.assert_any_call({
                        'prefix': 'dashboard set-grafana-api-url',
                        'value': 'https://test:3000'
                    })
예제 #3
0
    def test_daemon_action(self, cephadm_module: CephadmOrchestrator):
        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            with with_daemon(cephadm_module,
                             RGWSpec(service_id='myrgw.foobar'),
                             CephadmOrchestrator.add_rgw, 'test') as daemon_id:

                c = cephadm_module.daemon_action('redeploy',
                                                 'rgw.' + daemon_id)
                assert wait(
                    cephadm_module, c
                ) == f"Scheduled to redeploy rgw.{daemon_id} on host 'test'"

                for what in ('start', 'stop', 'restart'):
                    c = cephadm_module.daemon_action(what, 'rgw.' + daemon_id)
                    assert wait(
                        cephadm_module, c
                    ) == F"Scheduled to {what} rgw.{daemon_id} on host 'test'"

                # Make sure, _check_daemons does a redeploy due to monmap change:
                cephadm_module._store['_ceph_get/mon_map'] = {
                    'modified':
                    datetime.datetime.utcnow().strftime(CEPH_DATEFMT),
                    'fsid': 'foobar',
                }
                cephadm_module.notify('mon_map', None)

                cephadm_module._check_daemons()
예제 #4
0
    def test_daemon_check_extra_config(self, _run_cephadm,
                                       cephadm_module: CephadmOrchestrator):
        _run_cephadm.return_value = ('{}', '', 0)

        with with_host(cephadm_module, 'test'):

            # Also testing deploying mons without explicit network placement
            cephadm_module.check_mon_command({
                'prefix': 'config set',
                'who': 'mon',
                'name': 'public_network',
                'value': '127.0.0.0/8'
            })

            cephadm_module.cache.update_host_devices_networks(
                'test', [], {
                    "127.0.0.0/8": ["127.0.0.1"],
                })

            with with_service(cephadm_module, ServiceSpec(service_type='mon'),
                              CephadmOrchestrator.apply_mon,
                              'test') as d_names:
                [daemon_name] = d_names

                cephadm_module._set_extra_ceph_conf('[mon]\nk=v')

                cephadm_module._check_daemons()

                _run_cephadm.assert_called_with(
                    'test',
                    'mon.test',
                    'deploy',
                    ['--name', 'mon.test', '--reconfig', '--config-json', '-'],
                    stdin='{"config": "\\n\\n[mon]\\nk=v\\n", "keyring": ""}',
                    image='')
예제 #5
0
    def test_daemon_check(self, cephadm_module: CephadmOrchestrator, action):
        with with_host(cephadm_module, 'test'):
            with with_service(cephadm_module, ServiceSpec(service_type='grafana'), CephadmOrchestrator.apply_grafana, 'test') as d_names:
                [daemon_name] = d_names

                cephadm_module._schedule_daemon_action(daemon_name, action)

                assert cephadm_module.cache.get_scheduled_daemon_action(
                    'test', daemon_name) == action

                cephadm_module._check_daemons()

                assert cephadm_module.cache.get_scheduled_daemon_action('test', daemon_name) is None
예제 #6
0
    def test_daemon_action(self, _ceph_get, cephadm_module: CephadmOrchestrator):
        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            c = cephadm_module.list_daemons(refresh=True)
            wait(cephadm_module, c)
            c = cephadm_module.daemon_action('redeploy', 'rgw', 'myrgw.foobar')
            assert wait(cephadm_module, c) == ["Deployed rgw.myrgw.foobar on host 'test'"]

            for what in ('start', 'stop', 'restart'):
                c = cephadm_module.daemon_action(what, 'rgw', 'myrgw.foobar')
                assert wait(cephadm_module, c) == [what + " rgw.myrgw.foobar from host 'test'"]

            now = datetime.datetime.utcnow().strftime(CEPH_DATEFMT)
            _ceph_get.return_value = {'modified': now}

            cephadm_module._check_daemons()

            assert_rm_daemon(cephadm_module, 'rgw.myrgw.foobar', 'test')
예제 #7
0
    def test_daemon_action(self, cephadm_module: CephadmOrchestrator):

        cephadm_module.service_cache_timeout = 10
        with with_host(cephadm_module, 'test'):
            c = cephadm_module.list_daemons(refresh=True)
            wait(cephadm_module, c)
            assert len(c.result) == 1
            c = cephadm_module.daemon_action('redeploy', 'rgw', 'myrgw.foobar')
            assert wait(cephadm_module, c) == ["Deployed rgw.myrgw.foobar on host 'test'"]

            for what in ('start', 'stop', 'restart'):
                c = cephadm_module.daemon_action(what, 'rgw', 'myrgw.foobar')
                assert wait(cephadm_module, c) == [what + " rgw.myrgw.foobar from host 'test'"]

            # Make sure, _check_daemons does a redeploy due to monmap change:
            cephadm_module._store['_ceph_get/mon_map'] = {
                'modified': datetime.datetime.utcnow().strftime(CEPH_DATEFMT),
                'fsid': 'foobar',
            }
            cephadm_module.notify('mon_map', None)

            cephadm_module._check_daemons()

            assert_rm_daemon(cephadm_module, 'rgw.myrgw.foobar', 'test')