Skip to content

mgr/cephadm: move ok_to_stop to CephadmService #35503

Merged
sebastian-philipp merged 4 commits intoceph:masterfrom
sebastian-philipp:rm-daemon-ok-to-stop
Jun 25, 2020
Merged

mgr/cephadm: move ok_to_stop to CephadmService #35503
sebastian-philipp merged 4 commits intoceph:masterfrom
sebastian-philipp:rm-daemon-ok-to-stop

Conversation

@sebastian-philipp
Copy link
Contributor

This PR is on the edge of being unnecessary. MDS is the only service that will benefit from this. Still:

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@sebastian-philipp
Copy link
Contributor Author

todo for tomorrow:

    @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}'))
    @mock.patch("cephadm.services.cephadmservice.CephadmService.ok_to_stop")
    def test_daemon_ok_to_stop(self, ok_to_stop, cephadm_module: CephadmOrchestrator):
        spec = ServiceSpec(
            'mds',
            service_id='fsname',
            placement=PlacementSpec(hosts=['host1', 'host2'])
        )
        with with_host(cephadm_module, 'host1'), with_host(cephadm_module, 'host2'):
            c = cephadm_module.apply_mds(spec)
            out = wait(cephadm_module, c)
            match_glob(out, "Scheduled mds.fsname update...")
            cephadm_module._apply_all_services()
    
            spec.placement.set_hosts(['host2'])
    
            c = cephadm_module.apply_mds(spec)
            out = wait(cephadm_module, c)
            match_glob(out, "Scheduled mds.fsname update...")
            cephadm_module._apply_all_services()
    
>           [daemon] = cephadm_module.cache.daemons['host1'].keys()
E           ValueError: not enough values to unpack (expected 1, got 0)

Copy link
Contributor

@mgfritch mgfritch left a comment

Choose a reason for hiding this comment

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

👍 generally moving these to a CephadmService is much cleaner ... I’m just a little worried about some of the edge cases where service_type doesn’t agree with TYPE...

@sebastian-philipp
Copy link
Contributor Author

self._remove_daemon(d.name(), d.hostname)
r = True
to_remove = [d for d in daemons if d.hostname not in target_hosts]
while to_remove and not self.cephadm_services[daemon_type].ok_to_stop([d.daemon_id for d in to_remove]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any sense to use list construction instead of iterator?

new_mons = [m for m in mons if m != mon_id]
new_quorum = [m for m in j['quorum_names'] if m != mon_id]
if len(new_quorum) > len(new_mons) / 2:
logger.info('Safe to remove mon.%s: new quorum should be %s (from %s)' % (mon_id, new_quorum, new_mons))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a logger.info, then it is better to right?

logger.info('Safe to remove mon.%s: new quorum should be %s (from %s)', mon_id, new_quorum, new_mons)

Otherwise, why not keep the same style using f' ' strings?

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

if len(new_quorum) > len(new_mons) / 2:
logger.info('Safe to remove mon.%s: new quorum should be %s (from %s)' % (mon_id, new_quorum, new_mons))
return
raise OrchestratorError('Removing %s would break mon quorum (new quorum %s, new mons %s)' % (mon_id, new_quorum, new_mons))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

ok = self.mgr.cephadm_services[s.daemon_type].ok_to_stop([s.daemon_id])

if ok:
logger.info('Upgrade: It is presumed safe to stop %s.%s' %
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above regarding logger.info

logger.info('Upgrade: It is presumed safe to stop %s.%s' %
(s.daemon_type, s.daemon_id))
return True
logger.info('Upgrade: It is NOT safe to stop %s.%s' %
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above regarding logger.info

# To backpopulate the .hosts attribute when using labels or count
# in the orchestrator backend.
self.hosts = hosts
if all([isinstance(host, HostPlacementSpec) for host in hosts]):
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no need to construct a list

names = [f'{self.TYPE}.{d_id}' for d_id in daemon_ids]

if self.TYPE not in ['mon', 'osd', 'mds']:
logger.info('Upgrade: It is presumed safe to stop %s' % names)
Copy link
Contributor

Choose a reason for hiding this comment

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

% names => , names?

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Copy link
Contributor

@mgfritch mgfritch left a comment

Choose a reason for hiding this comment

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

lgtm, this structure will make future PRs much cleaner!

@sebastian-philipp sebastian-philipp added the wip-swagner-testing My Teuthology tests label Jun 24, 2020
@sebastian-philipp
Copy link
Contributor Author

unfortunately, I think this is blocked, till the upgrade test is working again.

@sebastian-philipp sebastian-philipp changed the title mgr/cephadm: move ok_to_stop to CephadmService [Blocked by #35740] mgr/cephadm: move ok_to_stop to CephadmService Jun 24, 2020
@sebastian-philipp
Copy link
Contributor Author

@sebastian-philipp
Copy link
Contributor Author

jenkins test docs

@sebastian-philipp sebastian-philipp changed the title [Blocked by #35740] mgr/cephadm: move ok_to_stop to CephadmService mgr/cephadm: move ok_to_stop to CephadmService Jun 25, 2020
@sebastian-philipp sebastian-philipp merged commit 21a9fb9 into ceph:master Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants