-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rgw: elastic: fixes for supporting Elasticsearch versions >= 5.0 #21852
Conversation
src/rgw/rgw_sync_module_es.cc
Outdated
@@ -472,9 +578,11 @@ class RGWElasticHandleRemoteObjCBCR : public RGWStatRemoteObjCBCR { | |||
string path = conf->get_obj_path(bucket_info, key); | |||
es_obj_metadata doc(sync_env->cct, conf, bucket_info, key, mtime, size, attrs, versioned_epoch); | |||
|
|||
std::map <string, string> hdrs = {{ "content-type", "application/json" }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content-Type is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
|
||
es_index_settings settings(conf->num_replicas, conf->num_shards); | ||
es_index_mappings mappings; | ||
if (es_info.version >= ESVersion(5,0)) { | ||
ldout(sync_env->cct, 0) << "elasticsearch: using text type for string index mappings " << dendl; | ||
mappings.string_type = ESType::Text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Keyword is enough, we don't need analyse most field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess for id like fields we can go for keyword, text is still better for names, like the object/bucket names since keywords expect the exact search term
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theanalyst looking good, just minor comments
src/rgw/rgw_cr_rest.h
Outdated
@@ -264,6 +264,17 @@ class RGWPutRESTResourceCR : public RGWSendRESTResourceCR<S, T> { | |||
: RGWSendRESTResourceCR<S, T>(_cct, _conn, _http_manager, | |||
"PUT", _path, | |||
_params, nullptr, _input, _result) {} | |||
|
|||
RGWPutRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theanalyst indentation maybe?
src/rgw/rgw_sync_module_es.cc
Outdated
bool operator >= (const ESVersion& v1, const ESVersion& v2){ | ||
if (v1.major_ver > v2.major_ver) | ||
return true; | ||
else if (v1.major_ver == v2.major_ver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could do it shorter:
if (v1.major_ver == v2.major_ver)
return v1.minor_ver >= v2.minor_ver;
return v1.major_ver > v2.major_ver;
@theanalyst do we have a tracker issue for this one? will need to set it for backport |
fb824ed
to
6393b5b
Compare
src/rgw/rgw_sync_module_es.cc
Outdated
int major_ver; | ||
int minor_ver; | ||
|
||
ESVersion(int _major, int _minor): major_ver(_major), minor_ver(_minor) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could remove the trailing ;
.
src/rgw/rgw_sync_module_es.cc
Outdated
int minor_ver; | ||
|
||
ESVersion(int _major, int _minor): major_ver(_major), minor_ver(_minor) {}; | ||
ESVersion(): major_ver(0), minor_ver(0) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
src/rgw/rgw_sync_module_es.cc
Outdated
ESVersion(int _major, int _minor): major_ver(_major), minor_ver(_minor) {}; | ||
ESVersion(): major_ver(0), minor_ver(0) {}; | ||
|
||
void from_str(const char* s){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space before {
.
src/rgw/rgw_sync_module_es.cc
Outdated
sscanf(s, "%d.%d", &major_ver, &minor_ver); | ||
} | ||
|
||
std::string to_str(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could mark this method const
.
src/rgw/rgw_sync_module_es.cc
Outdated
@@ -161,13 +209,47 @@ struct ElasticConfig { | |||
|
|||
using ElasticConfigRef = std::shared_ptr<ElasticConfig>; | |||
|
|||
std::optional<const char*> es_type_to_str(const ESType& t) { | |||
switch(t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space after switch
.
src/rgw/rgw_sync_module_es.cc
Outdated
|
||
es_dump_type(const char *t, const char *f = nullptr, bool a = false) : type(t), format(f), analyzed(a) {} | ||
|
||
es_dump_type(ESType t, const char *f=nullptr, bool a = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be more consistent regarding to adding spaces around =
src/rgw/rgw_sync_module_es.h
Outdated
Text, | ||
Keyword, | ||
|
||
/*Numeric Types */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space after *
This commit introduces an enum mapping various ES types. Also encode_json now has a new member for string type so that this can be changed easily when upgrading ES versions for eg. wherein new ES engines do not support the string type anymore. Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
Adding another constructor overload for cases when we need to override the default headers Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
Getting the basic information from elasticsearch, while we're only currently interested in elasic search version, other data such as the ES cluster name etc may be useful in the future as well. Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
from Elasticsearch 5.0+ the type string is deprecated, while it is still allowed in 5.0, it returns a 400 error on 6.0 clusters as this type is fully removed. We now determine the es version while initializing the cluster from elasticsearch's default endpoint and use that to determine what string type to use. This way we support both 2.x and 5.x,6.x es versions as we default to string type for clusters < 5.0 Fixes: http://tracker.ceph.com/issues/22877 Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
jenkins test this please (dashboard related failures) |
@theanalyst pls rebase --- pr 21852 --- pulling https://github.com/theanalyst/ceph.git branch wip-es6-fixes
|
This is superceded by #22030 |
This series of commits introduces support for ES clusters>= 5.0 where the string type is deprecated and 6.0 clusters where the type is invalid. We determine the ESversion and then decide on the string type to use, using text type for ES version >= 5.0.
An enum called ESType is introduced having mappings to various ESTypes and this is later used in dump_type. Also introduces structures for ES version info and cluster name info which we parse from ES endpoint, while only the version info is used to determine the string type, there might be use for storing away the es cluster name and uuid for future use.
Fixes: http://tracker.ceph.com/issues/22877