Skip to content
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: es: support username and password for ES #22030

Closed
wants to merge 7 commits into from

Conversation

theanalyst
Copy link
Member

For ES endpoints terminated with a username and password, either via xpack or
fronted by another webserver with http basic auth, we now support "username" and
"password" configurable which should be capable of doing HTTP basic
authentication

Fixes: https://tracker.ceph.com/issues/23655

This is built atop of #21852 and basically first adds support for headers in get http crs, and then adds these headers as a part of all the ES requests

@theanalyst
Copy link
Member Author

@yuriw
Copy link
Contributor

yuriw commented Jul 23, 2018

@theanalyst pls rebase

--- pr 22030 --- pulling https://github.com/theanalyst/ceph.git branch wip-es6-auth
remote: Counting objects: 32, done.
remote: Total 32 (delta 26), reused 26 (delta 26), pack-reused 6
Unpacking objects: 100% (32/32), done.
From https://github.com/theanalyst/ceph

  • branch wip-es6-auth -> FETCH_HEAD
    Auto-merging src/rgw/rgw_sync_module_es.cc
    CONFLICT (file/directory): There is a directory with name src/dmclock in 67fe083. Adding src/dmclock as src/dmclock~HEAD
    Automatic merge failed; fix conflicts and then commit the result.
    Traceback (most recent call last):
    File "/home/yuriw/wip_master/src/script/build-integration-branch", line 62, in
    assert not r
    AssertionError

@theanalyst
Copy link
Member Author

@yuriw updated..

@theanalyst
Copy link
Member Author

@yehudasa can you review this once again, this was the same as the fixes for ES versions > 5.0 + support for ES deployments with a username + pw

@theanalyst
Copy link
Member Author

@yehudasa ping, this contains the ES6 support + creating a username/pw for setups that have X-pack configured. I closed the earlier approved #21852, this contains that pr + one commit for username/pw support

yehudasa
yehudasa previously approved these changes Sep 14, 2018
Copy link
Member

@yehudasa yehudasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theanalyst looks great, see my comment

if (v1.major_ver == v2.major_ver)
return v1.minor_ver >= v2.minor_ver;

return v1.major_ver > v2.major_ver;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be >= here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the first equality should catch this, having said that this does look non intuitive, I'll collapse this to a one liner

@theanalyst
Copy link
Member Author

@yehudasa updated to use a std::pair as the ESVersion, and just a wrapper struct to parse the nested version json.


ESVersion get_version() {
int _major,_minor;
sscanf(s.c_str(), "%d.%d", &_major, &_minor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any possibility of parse error (including empty input) here? Remember to check the result of sscanf(), if you'd like to use scanf() here and there's any possibility of error. Or, consider using std::stoi(), which also has error detection (note that the older C atoi() doesn't give you a way to do this) and supports std::string directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theanalyst should at least dump error and set defaults to _major and _minor.

@stale
Copy link

stale bot commented Dec 10, 2018

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you are a maintainer or core committer, please follow-up on this issue to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@stale stale bot added the stale label Dec 10, 2018
@stale stale bot removed the stale label Dec 11, 2018
@theanalyst theanalyst force-pushed the wip-es6-auth branch 3 times, most recently from bdffb4f to 44ae56b Compare December 12, 2018 15:56
@theanalyst
Copy link
Member Author

rebased against current master, also have made the es_version_decoder throw a JSONDecoder error in case of a failed scanf, since the error will be caught by the rest coroutine which will ultimately raise an -EINVAL.

@theanalyst
Copy link
Member Author

Passes local testing, @yehudasa can you take a look

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>
Adding support to add additional headers as a part of GET and READ requests.

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
For ES endpoints terminated with a username and password, either via xpack or
fronted by another webserver with http basic auth, we now support "username" and
"password" configurable which should be capable of doing HTTP basic
authentication

Fixes: https://tracker.ceph.com/issues/23655
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
using std::pair as the version struct. Another decoder class is currently
introduced as we have a nested json type for version right now.

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
@theanalyst
Copy link
Member Author

@yehudasa updated against the current master, and tested locally, can you take a look

@yehudasa
Copy link
Member

@theanalyst still looks good

@yehudasa
Copy link
Member

@theanalyst feel free to merge if passing tests. We'll want to backport it to mimic.

@yehudasa
Copy link
Member

@theanalyst though note comment by @chardan

@yehudasa yehudasa dismissed their stale review January 25, 2019 19:12

Need to revise string to text conversion for ES 5.x+


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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theanalyst note migration instructions here:
https://www.elastic.co/blog/strings-are-dead-long-live-strings
string converts into either text or keyword, depending on the analyzed state. We also need to make sure the index field is being created correctly (as code is written now, it doesn't create it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the find, I'll modify dump_type to handle these cases

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing the same behaviour even without the patch in ES 5.6, we get the double mapping to both text and keyword. I assume name fields should be text types and most of the fields like IDs should be keywords

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So reading more into this it seems even mapping types are already deprecated and going away in the next ES version. https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html, not sure how exactly we're supposed to be mapping types then. For now I'll decide based on "analyzed" field whether we dump a keyword or a text if the type set is not a string already.

@yehudasa
Copy link
Member

@theanalyst I did some work on this, see here:
#26106

@theanalyst
Copy link
Member Author

taken up in #26106

@theanalyst theanalyst closed this Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants