Skip to content

rgw: Added caching for S3 credentials retrieved from keystone - #26095

Merged
mattbenjamin merged 2 commits into
ceph:masterfrom
bbc:s3secretcache
Mar 18, 2019
Merged

mattbenjamin merged 2 commits into
ceph:masterfrom
bbc:s3secretcache

Conversation

@jamesba

@jamesba jamesba commented Jan 23, 2019

Copy link
Copy Markdown
Contributor

When providing an S3 compatible interface previous behaviour has been to cache the
access token but request verification of the signature for every request from keystone.
This causes keystone to be quite a performance bottleneck especially for instalations
with high levels of S3 traffic.

In this commit a change is made to perform the verification of S3 request signatures
inside the radosgw process, thereby seriously reducing the number of requests that need
to be made to keystone. To do this a shared S3 secret key is obtained from keystone and
kept in a local cache.

Signed-off-by: James Weaver [email protected]

@jamesba

jamesba commented Jan 23, 2019

Copy link
Copy Markdown
Contributor Author

As an example our 700 30MB requests per second fully maxed out 12 CPU cores on keystone and generated around 30Mb/s of authentication traffic. Post this change the authentication traffic to and from keystone is now negligible (and the keystone cpu load is similarly negligible), and the latency of each of our S3 requests has dropped by about 40%.

The benefit might well be even larger with smaller objects.

@jrosser

jrosser commented Jan 23, 2019

Copy link
Copy Markdown

This code is inspired by the Swift keystone-middleware s3 python code which provides a layer of token caching using memcached. In this patch a similar approach is applied within radosgw using C++ constructs.

@mattbenjamin mattbenjamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems like a valid complement to the STS integration with keystone, which avoids the need for a cache, but has different trade-offs--for an environment where keystone has ec2 credentials for an account, using sts::lite should be an option; did you folks look at that?

Comment thread src/rgw/rgw_auth_keystone.cc Resolved
Comment thread src/rgw/rgw_auth_keystone.h Resolved
Comment thread src/rgw/rgw_auth_keystone.h Resolved
@jrosser

jrosser commented Jan 23, 2019

Copy link
Copy Markdown

this seems like a valid complement to the STS integration with keystone, which avoids the need for a cache, but has different trade-offs--for an environment where keystone has ec2 credentials for an account, using sts::lite should be an option; did you folks look at that?

@jamesba See http://docs.ceph.com/docs/master/radosgw/STSLite/

@mattbenjamin In this situation we are not always in control of the client implementation so needing to patch boto would be unfortunate. The STS stuff is however interesting.

@mattbenjamin

Copy link
Copy Markdown
Contributor

@jamesba hacking boto3 was/is--I think, @pritha-srivastava?--attempts to make boto do the full STS round trip, but iiuc, the only thing it doesn't do unpatched is the GetSessionToken, so iiuc again, that step, which is done once/infrequently, could be done with something outboard?

@pritha-srivastava

Copy link
Copy Markdown
Contributor

@jamesba hacking boto3 was/is--I think, @pritha-srivastava?--attempts to make boto do the full STS round trip, but iiuc, the only thing it doesn't do unpatched is the GetSessionToken, so iiuc again, that step, which is done once/infrequently, could be done with something outboard?

You are right Matt, only GetSessionToken requires boto to be patched, once the temporary creds are obtained, patching boto is not needed.

Comment thread src/rgw/rgw_auth_keystone.cc Resolved
@mattbenjamin

Copy link
Copy Markdown
Contributor

@jamesba do you folks have a timeline for pushing some updates here? We'd like to incorporate this, when ready.

@jrosser

jrosser commented Feb 1, 2019

Copy link
Copy Markdown

@jamesba do you folks have a timeline for pushing some updates here? We'd like to incorporate this, when ready.

@mattbenjamin we are also keen to get this merged as it is working very well for us, I would hope that we can get an update pushed early next week. We are suffering slightly from parallel builds failing for mimic which makes the turn-round time to test things very slow.

@mattbenjamin

Copy link
Copy Markdown
Contributor

@jamesba woot, thanks for the update

…tials

When providing an S3 compatible interface previous behaviour has been to cache the
access token but request verification of the signature for every request from keystone.
This causes keystone to be quite a performance bottleneck especially for instalations
with high levels of S3 traffic.

In this commit a change is made to perform the verification of S3 request signatures
inside the radosgw process, thereby seriously reducing the number of requests that need
to be made to keystone. To do this a shared S3 secret key is obtained from keystone and
kept in a local cache.

Signed-off-by: James Weaver <[email protected]>
Now makes use of existing method for generating a signature for an S3 request.

Signed-off-by: James Weaver <[email protected]>
@jamesba

jamesba commented Feb 4, 2019

Copy link
Copy Markdown
Contributor Author

@mattbenjamin Have made the requested changes. Now makes use of the existing signing mechanisms.

@mattbenjamin mattbenjamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this looks good to me, with ack from pritha and marcus; marcus has a parallel change that touches the keystone token cache, and I want him to elucidate how they interact

lock(),
max(cct->_conf->rgw_keystone_token_cache_size),
s3_token_expiry_length(300) {
s3_token_expiry_length(300, 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missed this in the first path; this should probably be configurable? I don't think that's a problem for now

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mattbenjamin we did try to make this configurable during testing but that only led to segfaults, the proper way to add new config options is a bit opaque. Is there a good guide or example for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any progress on this?

@mattbenjamin

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox can I get you to do your review of this?

@mdw-at-linuxbox

Copy link
Copy Markdown
Contributor

The main reservation I have about this is I think there will be sites that don't want to export all their user tokens to rgw this way - is there a way to maintain the ability for the "old" functionality as well?

Token revocation may be an issue as well - doesn't appear to be any datapath for this. I don't think most sites will care about this - something to think about for the future.

This change doesn't directly interact with anything I do. It duplicates the token cache to make a new "secret cache" - parallel logic to token_cache. It could benefit from the same set of changes I did for token_cache - and could also benefit from using a shared type instead of duplicating logic.

@mattbenjamin

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox @cbodley I think this is pass. There is, in addition to the mon and osd ones, a radosgw leak in a request pipeline; it doesn't seem to have any relationship to the PR:
http://qa-proxy.ceph.com/teuthology/mbenjamin-2019-03-18_01:51:09-rgw-wip-bbc-s3secretcache-distro-basic-smithi/3742900/remote/smithi148/log/valgrind/c1.client.0.log.gz

@mattbenjamin

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox those suggestions make sense; I think we should merge now and improve rather than delaying further, however

@jrosser

jrosser commented Mar 18, 2019

Copy link
Copy Markdown

We are open to adding config options to enable/disable this function, and maybe tune the cache lifetime. We are however unable to add config options without the code segfaulting - see @jamesba requesting help with this in previous comments. Happy to add that to this PR or a subsequent one as required if we can get some guidance.

@mattbenjamin

Copy link
Copy Markdown
Contributor

@jrosser you're welcome to help; I'd like to take this now, @mdw-at-linuxbox may be able to help coordinate on adjustments, or work through the issues; great work here, sorry it took a long time to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants