]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't send raw date header to elasticsearch
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 1 May 2017 23:08:31 +0000 (16:08 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:26:57 +0000 (13:26 -0700)
parse the header, and encode it in the json doc using
a format that ES can understand. Skip header if fails to
parse.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_es.cc

index efd1f4b32c8a4dbfcd3b5716c3d28f75ec3b76ef..4842f8b90f57bdeeb664f047b9f1ab6feaaefcbc 100644 (file)
@@ -374,9 +374,23 @@ struct es_obj_metadata {
     if (!custom_date.empty()) {
       f->open_array_section("custom-date");
       for (auto i : custom_date) {
+        /*
+         * try to exlicitly parse date field, otherwise elasticsearch could reject the whole doc,
+         * which will end up with failed sync
+         */
+        real_time t;
+        int r = parse_time(i.second.c_str(), &t);
+        if (r < 0) {
+          ldout(cct, 20) << __func__ << "(): failed to parse time (" << i.second << "), skipping encoding of custom date attribute" << dendl;
+          continue;
+        }
+
+        string time_str;
+        rgw_to_iso8601(t, &time_str);
+
         f->open_object_section("entity");
         ::encode_json("name", i.first.c_str(), f);
-        ::encode_json("value", i.second, f);
+        ::encode_json("value", time_str.c_str(), f);
         f->close_section();
       }
       f->close_section();