]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: only log (as in ops logging) certain operations
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 5 Aug 2013 18:38:27 +0000 (11:38 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 5 Aug 2013 19:30:17 +0000 (12:30 -0700)
Fixes: #5875
ops logging should (at this point) should only include object
store related operations.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
src/rgw/rgw_main.cc
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h

index 07bf07366d5bcca946d5acc30de71ff741640c96..e10d4d0aeed67d55ba9ce860562f58e467d8766d 100644 (file)
@@ -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;
index a0870708c440d38d276632f3a5e0ad94dbe7f176..ee73bb94fa5ec872dced1ff02ba9c280fb69721b 100644 (file)
@@ -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;
index ded5b88366a6cf555ab2e4d4eebcf5742f36b623..b65efb3de3e4b99bb28dde37ef0bc0352fa2cc6a 100644 (file)
@@ -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);
   }