Skip to content

mon/MonClient: handle ms_handle_fast_authentication return#52939

Merged
batrick merged 1 commit intoceph:mainfrom
batrick:i62382
Aug 6, 2024
Merged

mon/MonClient: handle ms_handle_fast_authentication return#52939
batrick merged 1 commit intoceph:mainfrom
batrick:i62382

Conversation

@batrick
Copy link
Member

@batrick batrick commented Aug 10, 2023

Fixes: https://tracker.ceph.com/issues/62382

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
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 cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@batrick batrick added the core label Aug 10, 2023
@github-actions github-actions bot added cephfs Ceph File System mgr mon labels Aug 10, 2023
@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@rzarzynski
Copy link
Contributor

@batrick: #52292 is merged.

@batrick
Copy link
Member Author

batrick commented Aug 30, 2023

I think to test this would require having caps which parse correctly for the mon's AuthMonitor but are too new to parse for an older OSD/mgr/mds. Would you agree @idryomov @rzarzynski ?

@idryomov
Copy link
Contributor

I think to test this would require having caps which parse correctly for the mon's AuthMonitor but are too new to parse for an older OSD/mgr/mds.

Most likely, given that the only thing these handlers do is parse the caps string.

@batrick
Copy link
Member Author

batrick commented Oct 9, 2023

I think to test this would require having caps which parse correctly for the mon's AuthMonitor but are too new to parse for an older OSD/mgr/mds.

Most likely, given that the only thing these handlers do is parse the caps string.

Okay, I'll have to think of an easy way to test this. Alternatively we can just skip tests as risk is low, IMO.

virtual int ms_handle_fast_authentication(Connection *con) {
return 0;
virtual bool ms_handle_fast_authentication(Connection *con) {
return false;
Copy link
Member Author

Choose a reason for hiding this comment

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

@idryomov actually this should probably be true, yes? Otherwise every dispatcher that does not implement this method will fail here. I'll make this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's dangerous to provide a default "yup, authenticated" implementation. I would rather make this a pure virtual.

Copy link
Member Author

Choose a reason for hiding this comment

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

So turning this into a pure virtual broke the build and required every dispatcher to be modified, even in places where it makes no sense, e.g. MonClient. I decided it's better to leave it as a regular virtual method which returns true.

@batrick batrick marked this pull request as ready for review October 20, 2023 14:47
@batrick batrick requested a review from a team as a code owner October 20, 2023 14:47
@batrick
Copy link
Member Author

batrick commented Oct 20, 2023

I think to test this would require having caps which parse correctly for the mon's AuthMonitor but are too new to parse for an older OSD/mgr/mds.

Most likely, given that the only thing these handlers do is parse the caps string.

Given how brittle the test would be, I think we'll just take this as-is. Please review at your convenience @idryomov .

Copy link
Contributor

@idryomov idryomov left a comment

Choose a reason for hiding this comment

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

I see two ms_handle_fast_authentication() calls in Monitor::handle_auth_request() where the return value is not checked. Is that intentional?

virtual int ms_handle_fast_authentication(Connection *con) {
return 0;
virtual bool ms_handle_fast_authentication(Connection *con) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's dangerous to provide a default "yup, authenticated" implementation. I would rather make this a pure virtual.

@idryomov
Copy link
Contributor

Given how brittle the test would be, I think we'll just take this as-is.

This is up to @rzarzynski.

@batrick
Copy link
Member Author

batrick commented Oct 23, 2023

I see two ms_handle_fast_authentication() calls in Monitor::handle_auth_request() where the return value is not checked. Is that intentional?

Taking a look at this now. Done.

AuthCapsInfo &caps_info = con->get_peer_caps_info();
if (caps_info.allow_all) {
s->caps.set_allow_all();
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

<< " failed to parse caps '" << str << "'" << dendl;
ret = -EACCES;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

dout(10) << __func__ << " session " << s
<< " " << s->entity_name
<< " has caps " << s->caps << " '" << str << "'" << dendl;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

} else {
dout(10) << __func__ << " session " << s << " " << s->entity_name
<< " failed to parse caps '" << str << "'" << dendl;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

return false;
}
} else {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This handles the original ret eq 0 case (neither allow_all nor caps_info.caps.length() > 0). This blurs the information with EACCESS but I think it's fine.

s->caps.set_allow_all();
s->authenticated = true;
ret = 1;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

<< " in auth db" << dendl;
str.clear();
ret = -EACCES;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

}
if (s->caps.parse(str, NULL)) {
s->authenticated = true;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

} else {
derr << __func__ << " unparseable caps '" << str << "' for "
<< con->get_peer_entity_name() << dendl;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

virtual int ms_handle_fast_authentication(Connection *con) {
return 0;
virtual bool ms_handle_fast_authentication(Connection *con) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for not going pure virtual?

Copy link
Member Author

Choose a reason for hiding this comment

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

Dispatchers that don't handle authentication would need to have the method which seemed unnecessarily obtrusive.

Copy link
Contributor

Choose a reason for hiding this comment

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

I share the @idryomov's concern.

How about introducing an intermediary stage (with the default implementation) in the inheritance hierarchy to address those auth-uninterested dispatchers explicitly?

$ grep -r ms_handle_fast_authentication ./
./mon/MonClient.cc:      handle_authentication_dispatcher->ms_handle_fast_authentication(con);
./mon/MonClient.cc:    handle_authentication_dispatcher->ms_handle_fast_authentication(con);
./mon/Monitor.h:  int ms_handle_fast_authentication(Connection *con) override;
./mon/AuthMonitor.cc:	  mon.ms_handle_fast_authentication(s->con.get()) > 0) {
./mon/Monitor.cc:      ms_handle_fast_authentication(con);
./mon/Monitor.cc:    ms_handle_fast_authentication(con);
./mon/Monitor.cc:int Monitor::ms_handle_fast_authentication(Connection *con)
./msg/Dispatcher.h:  virtual int ms_handle_fast_authentication(Connection *con) {
./mds/MDSDaemon.h:  int ms_handle_fast_authentication(Connection *con) override;
./mds/MDSDaemon.cc:int MDSDaemon::ms_handle_fast_authentication(Connection *con)
./mgr/DaemonServer.h:  int ms_handle_fast_authentication(Connection *con) override;
./mgr/DaemonServer.cc:int DaemonServer::ms_handle_fast_authentication(Connection *con)
./osd/OSD.h:    int ms_handle_fast_authentication(Connection *con) override {
./osd/OSD.h:  int ms_handle_fast_authentication(Connection *con) override;
./osd/OSD.cc:int OSD::ms_handle_fast_authentication(Connection *con)
./test/fio/fio_ceph_messenger.cc:  int ms_handle_fast_authentication(Connection *con) override {
./test/msgr/perf_msgr_client.cc:    int ms_handle_fast_authentication(Connection *con) override {
./test/msgr/test_msgr.cc:  int ms_handle_fast_authentication(Connection *con) override {
./test/msgr/test_msgr.cc:  int ms_handle_fast_authentication(Connection *con) override {
./test/msgr/test_msgr.cc:  int ms_handle_fast_authentication(Connection *con) override {
./test/msgr/perf_msgr_server.cc:  int ms_handle_fast_authentication(Connection *con) override {
$ grep -r public\ Dispatcher ./
./mon/Monitor.h:class Monitor : public Dispatcher,
./mon/MonClient.h:struct MonClientPinger : public Dispatcher,
./mon/MonClient.h:class MonClient : public Dispatcher,
./neorados/RADOSImpl.h:class RADOS : public Dispatcher
./tools/cephfs_mirror/ClusterWatcher.h:class ClusterWatcher : public Dispatcher {
./tools/cephfs/MDSUtility.h:class MDSUtility : public Dispatcher {
./librados/RadosClient.h:class librados::RadosClient : public Dispatcher,
./librbd/io/ImageDispatcher.h:class ImageDispatcher : public Dispatcher<ImageCtxT, ImageDispatcherInterface> {
./librbd/io/ObjectDispatcherInterface.h:  : public DispatcherInterface<ObjectDispatchInterface> {
./librbd/io/ObjectDispatcher.h:  : public Dispatcher<ImageCtxT, ObjectDispatcherInterface> {
./librbd/io/ImageDispatcherInterface.h:  : public DispatcherInterface<ImageDispatchInterface> {
./osdc/Objecter.h:class Objecter : public md_config_obs_t, public Dispatcher {
./mds/MDSDaemon.h:class MDSDaemon : public Dispatcher {
./mds/Beacon.h:class Beacon : public Dispatcher
./mds/MetricsHandler.h:class MetricsHandler : public Dispatcher {
./mds/MetricAggregator.h:class MetricAggregator : public Dispatcher {
./mgr/MgrStandby.h:class MgrStandby : public Dispatcher,
./mgr/DaemonServer.h:class DaemonServer : public Dispatcher, public md_config_obs_t
./mgr/MgrClient.h:class MgrClient : public Dispatcher
./osd/OSD.h:class OSD : public Dispatcher,
./osd/OSD.h:  struct HeartbeatDispatcher : public Dispatcher {
./test/crimson/test_messenger.cc:class FailoverSuite : public Dispatcher {
./test/crimson/test_messenger.cc:class FailoverTest : public Dispatcher {
./test/crimson/test_messenger.cc:class FailoverSuitePeer : public Dispatcher {
./test/crimson/test_messenger.cc:class FailoverTestPeer : public Dispatcher {
./test/crimson/test_messenger_peer.cc:class FailoverSuitePeer : public Dispatcher {
./test/crimson/test_messenger_peer.cc:class FailoverTestPeer : public Dispatcher {
./test/fio/fio_ceph_messenger.cc:class FioDispatcher : public Dispatcher {
./test/mon/test_mon_workloadgen.cc:class TestStub : public Dispatcher
./test/mon/test-mon-msg.cc:class MonClientHelper : public Dispatcher
./test/direct_messenger/test_direct_messenger.cc:class MockDispatcher : public Dispatcher {
./test/testmsgr.cc:class Admin : public Dispatcher {
./test/msgr/perf_msgr_client.cc:  class ClientDispatcher : public Dispatcher {
./test/msgr/test_msgr.cc:class FakeDispatcher : public Dispatcher {
./test/msgr/test_msgr.cc:class SyntheticDispatcher : public Dispatcher {
./test/msgr/test_msgr.cc:class MarkdownDispatcher : public Dispatcher {
./test/msgr/perf_msgr_server.cc:class ServerDispatcher : public Dispatcher {
./client/Client.h:class Client : public Dispatcher, public md_config_obs_t {

For many of them the burden could as low as running sed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think my concern in

#52939 (comment)

was not actually an issue. So I've changed the default return to false. That should render this conversation moot.

@batrick
Copy link
Member Author

batrick commented Jun 4, 2024

trivial rebase

@ceph ceph deleted a comment from github-actions bot Jun 4, 2024
@batrick
Copy link
Member Author

batrick commented Jun 10, 2024

jenkins test windows

@batrick
Copy link
Member Author

batrick commented Jun 11, 2024

This PR is under test in https://tracker.ceph.com/issues/66433.

@batrick
Copy link
Member Author

batrick commented Jun 13, 2024

This PR is under test in https://tracker.ceph.com/issues/66462.

batrick added a commit to batrick/ceph that referenced this pull request Jun 13, 2024
* refs/pull/52939/head:
	mon/MonClient: handle ms_handle_fast_authentication return
@batrick
Copy link
Member Author

batrick commented Jun 22, 2024

This PR is under test in https://tracker.ceph.com/issues/66609.

@batrick
Copy link
Member Author

batrick commented Jun 23, 2024

@idryomov @rzarzynski this is ready for merge; just blocked on your review please.

@batrick
Copy link
Member Author

batrick commented Jun 24, 2024

jenkins test make check arm64

@batrick
Copy link
Member Author

batrick commented Jun 28, 2024

jenkins test make check

@batrick
Copy link
Member Author

batrick commented Jul 2, 2024

jenkins test make check

@batrick
Copy link
Member Author

batrick commented Jul 2, 2024

jenkins test make check arm64

@batrick
Copy link
Member Author

batrick commented Jul 2, 2024

jenkins test api

@batrick
Copy link
Member Author

batrick commented Jul 3, 2024

jenkins test make check arm64

@batrick
Copy link
Member Author

batrick commented Jul 3, 2024

This PR is under test in https://tracker.ceph.com/issues/66822.

@batrick
Copy link
Member Author

batrick commented Jul 23, 2024

jenkins test make check arm64

1 similar comment
@batrick
Copy link
Member Author

batrick commented Jul 25, 2024

jenkins test make check arm64

@batrick
Copy link
Member Author

batrick commented Jul 26, 2024

This PR is under test in https://tracker.ceph.com/issues/67214.

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