From: Yehuda Sadeh Date: Mon, 1 May 2017 23:08:31 +0000 (-0700) Subject: rgw: don't send raw date header to elasticsearch X-Git-Tag: ses5-milestone6~9^2~3^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c13ec1c476ee18ef8e8885dd23872a21590b462a;p=ceph.git rgw: don't send raw date header to elasticsearch 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 --- diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index efd1f4b32c8..4842f8b90f5 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -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();