diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-08-05 11:38:27 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-08-05 11:38:27 -0700 |
commit | 7e68fb570e9d7fef91e22a63a1b3203e4059e97a (patch) | |
tree | 3e512fb81937a17709f0d37d823461b5e306bb27 | |
parent | a7bb8213854b9562c9cc957052ee8db7cb10ff9b (diff) | |
download | ceph-7e68fb570e9d7fef91e22a63a1b3203e4059e97a.tar.gz |
rgw: only log (as in ops logging) certain operationswip-5875
Fixes: #5875
ops logging should (at this point) should only include object
store related operations.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_main.cc | 22 | ||||
-rw-r--r-- | src/rgw/rgw_rest.cc | 5 | ||||
-rw-r--r-- | src/rgw/rgw_rest.h | 8 |
3 files changed, 27 insertions, 8 deletions
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 07bf07366d5..e10d4d0aeed 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -307,12 +307,16 @@ void RGWProcess::handle_request(RGWRequest *req) RGWOp *op = NULL; int init_error = 0; - RGWHandler *handler = rest->get_handler(store, s, &client_io, &init_error); + bool should_log = false; + RGWRESTMgr *mgr; + RGWHandler *handler = rest->get_handler(store, s, &client_io, &mgr, &init_error); if (init_error != 0) { abort_early(s, init_error); goto done; } + should_log = mgr->get_logging(); + req->log(s, "getting op"); op = handler->get_op(store); if (!op) { @@ -373,7 +377,9 @@ void RGWProcess::handle_request(RGWRequest *req) op->execute(); op->complete(); done: - rgw_log_op(store, s, (op ? op->name() : "unknown"), olog); + if (should_log) { + rgw_log_op(store, s, (op ? op->name() : "unknown"), olog); + } int http_ret = s->err.http_ret; @@ -420,6 +426,12 @@ int usage() return 0; } +static RGWRESTMgr *set_logging(RGWRESTMgr *mgr) +{ + mgr->set_logging(true); + return mgr; +} + /* * start up the RADOS connection and then handle HTTP messages as they come in */ @@ -525,16 +537,16 @@ int main(int argc, const char **argv) } if (apis_map.count("s3") > 0) - rest.register_default_mgr(new RGWRESTMgr_S3); + rest.register_default_mgr(set_logging(new RGWRESTMgr_S3)); if (apis_map.count("swift") > 0) { do_swift = true; swift_init(g_ceph_context); - rest.register_resource(g_conf->rgw_swift_url_prefix, new RGWRESTMgr_SWIFT); + rest.register_resource(g_conf->rgw_swift_url_prefix, set_logging(new RGWRESTMgr_SWIFT)); } if (apis_map.count("swift_auth") > 0) - rest.register_resource(g_conf->rgw_swift_auth_entry, new RGWRESTMgr_SWIFT_Auth); + rest.register_resource(g_conf->rgw_swift_auth_entry, set_logging(new RGWRESTMgr_SWIFT_Auth)); if (apis_map.count("admin") > 0) { RGWRESTMgr_Admin *admin_resource = new RGWRESTMgr_Admin; diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index a0870708c44..ee73bb94fa5 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -1210,7 +1210,7 @@ int RGWREST::preprocess(struct req_state *s, RGWClientIO *cio) } RGWHandler *RGWREST::get_handler(RGWRados *store, struct req_state *s, RGWClientIO *cio, - int *init_error) + RGWRESTMgr **pmgr, int *init_error) { RGWHandler *handler; @@ -1224,6 +1224,9 @@ RGWHandler *RGWREST::get_handler(RGWRados *store, struct req_state *s, RGWClient return NULL; } + if (pmgr) + *pmgr = m; + handler = m->get_handler(s); if (!handler) { *init_error = -ERR_METHOD_NOT_ALLOWED; diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index ded5b88366a..b65efb3de3e 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -263,13 +263,14 @@ class RGWHandler_SWIFT_Auth; class RGWHandler_ObjStore_S3; class RGWRESTMgr { + bool should_log; protected: map<string, RGWRESTMgr *> resource_mgrs; multimap<size_t, string> resources_by_size; RGWRESTMgr *default_mgr; public: - RGWRESTMgr() : default_mgr(NULL) {} + RGWRESTMgr() : should_log(false), default_mgr(NULL) {} virtual ~RGWRESTMgr(); void register_resource(string resource, RGWRESTMgr *mgr); @@ -278,6 +279,9 @@ public: virtual RGWRESTMgr *get_resource_mgr(struct req_state *s, const string& uri, string *out_uri); virtual RGWHandler *get_handler(struct req_state *s) { return NULL; } virtual void put_handler(RGWHandler *handler) { delete handler; } + + void set_logging(bool _should_log) { should_log = _should_log; } + bool get_logging() { return should_log; } }; class RGWREST { @@ -287,7 +291,7 @@ class RGWREST { public: RGWREST() {} RGWHandler *get_handler(RGWRados *store, struct req_state *s, RGWClientIO *cio, - int *init_error); + RGWRESTMgr **pmgr, int *init_error); void put_handler(RGWHandler *handler) { mgr.put_handler(handler); } |