Skip to content

rgw: opslog support record http_method/resource/prot_flag#17754

Closed
mikulely wants to merge 5 commits intoceph:masterfrom
mikulely:wip-support-operation
Closed

rgw: opslog support record http_method/resource/prot_flag#17754
mikulely wants to merge 5 commits intoceph:masterfrom
mikulely:wip-support-operation

Conversation

@mikulely
Copy link
Contributor

@mikulely mikulely commented Sep 15, 2017

Add three fields to support the Operation field[1] of s3 bucket
logging(#14841).

before

rgw opslog:

  • did't recognise op issued via different endpoints,eg can‘t recognise
    get request from s3/s3website endpoint.
  • missing parsed http_method,(this one is not the same as the one that
    stored in the http request, which is a string)
  • didn't record resource_type,which need to be recorded during http routing

after

we've add three new fields:

  • prot_flag
  • http_method
  • resource
[root@ceph-node1]~/jiaying/ceph/build# ../src/mrun j2 radosgw-admin  log show --object=2017-09-15-20-2a6a2c76-d968-4c0f-800d-49c412fd61b5.4106.1-test

       {
            "bucket": "test",
            "time": "2017-09-15 12:26:49.704525Z",
            "time_local": "2017-09-15 20:26:49.704525",
            "remote_addr": "127.0.0.1",
            "user": "testid",
            "operation": "PUT",
            "uri": "/test/777777777",
            "http_status": "200",
            "error_code": "",
            "bytes_sent": 0,
            "bytes_received": 5242880,
            "object_size": 5242880,
            "total_time": 476762,
            "user_agent": "",
            "referrer": "",
            "prot_flags": "REST",
            "resource": "OBJECT",
            "http_method": "PUT"
        }

[1] http://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html

Signed-off-by: Enming Zhang <enming.zhang@umcloud.com>
Signed-off-by: Enming Zhang <enming.zhang@umcloud.com>
ZVampirEM77 and others added 3 commits September 15, 2017 21:33
eg:

$ radosgw-admin log show

{
    "bucket_id": "4a039cfd-ab25-408a-9b04-51b6983b4ed0.4134.1",
    "bucket_owner": "tester",
    "bucket": "swiftcontainer1",
    "log_entries": [
        {
            "bucket": "swiftcontainer1",
            "time": "2017-09-07 12:20:34.903364Z",
            "time_local": "2017-09-07 20:20:34.903364",
            "remote_addr": "127.0.0.1",
            "user": "tester",
            "operation": "PUT",
            "uri": "/swift/v1/swiftcontainer1",
            "http_status": "201",
            "error_code": "Created",
            "bytes_sent": 0,
            "bytes_received": 0,
            "object_size": 0,
            "total_time": 157935,
            "user_agent": "python-swiftclient-3.4.0",
            "referrer": "",
            "prot_flags": "SWIFT_REST"
        }
    ],
    "log_sum": {
        "bytes_sent": 0,
        "bytes_received": 0,
        "total_time": 157935,
        "total_entries": 1
    }
}

Signed-off-by: Enming Zhang <enming.zhang@umcloud.com>
track resource type via following endpoints:

+ s3
+ s3website
+ swift auth
+ admin

Signed-off-by: Jiaying Ren <jiaying.ren@umcloud.com>
Signed-off-by: Jiaying Ren <jiaying.ren@umcloud.com>
}

if (s->prot_flags & RGW_REST_SWIFT && ! quoted) {
if (s->prot_flags & (RGW_REST_SWIFT | RGW_REST_SWIFT_AUTH)
Copy link
Member

Choose a reason for hiding this comment

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

@ZVampirEM77 etag is not going to be sent on swift auth request.


if (s->prot_flags & RGW_REST_SWIFT && !content_type) {
if (s->prot_flags & (RGW_REST_SWIFT | RGW_REST_SWIFT_AUTH)
&& !content_type) {
Copy link
Member

Choose a reason for hiding this comment

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

@ZVampirEM77 have you seen an actual issue here, or are you just pairing SWIFT_AUTH with SWIFT? I'm not sure this is needed, or won't break things somewhere.

formatter->dump_int("total_time", total_time);
formatter->dump_string("user_agent", entry.user_agent);
formatter->dump_string("referrer", entry.referrer);
formatter->dump_string("prot_flags", rgw_prot_flags[entry.prot_flags]);
Copy link
Member

Choose a reason for hiding this comment

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

@mikulely @ZVampirEM77 this is not going to work if flags have more than one bit set. Should generate a list of strings.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yehudasa in what conditions will flags have more than one bit set? i think there is a one-to-one correlation between a request and its protocol flags.

::encode(prot_flags, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &p) {
Copy link
Member

Choose a reason for hiding this comment

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

@ZVampirEM77 update version in decode() too

formatter->dump_string("user_agent", entry.user_agent);
formatter->dump_string("referrer", entry.referrer);
formatter->dump_string("prot_flags", rgw_prot_flags[entry.prot_flags]);
formatter->dump_string("resource", rgw_resources[entry.resource]);
Copy link
Member

Choose a reason for hiding this comment

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

@mikulely need to search for entry.resource and only dump if exists in rgw_resources, otherwise will create a new entry.

}

RGWOp *RGWHandler_Metadata::op_get() {
s->resource = RGW_RESOURCE_CATEGORY_METADATA;
Copy link
Member

Choose a reason for hiding this comment

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

there's a lot of duplicate stuff here, maybe can be moved into the constructor and when the handler is created you can pass in the req_state? Same goes to other handlers

formatter->dump_string("referrer", entry.referrer);
formatter->dump_string("prot_flags", rgw_prot_flags[entry.prot_flags]);
formatter->dump_string("resource", rgw_resources[entry.resource]);
formatter->dump_string("http_method", rgw_http_methods[entry.http_method]);
Copy link
Member

Choose a reason for hiding this comment

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

@ZVampirEM77 how is this different from the original method string?

Copy link
Contributor

Choose a reason for hiding this comment

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

@yehudasa the original method string is like OP_GET etc which is not compatible with AWS S3 GET

int prot_flags;
headers_map x_headers;
int resource;
int http_method;
Copy link
Member

Choose a reason for hiding this comment

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

missing initialization, where resource is initialized.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yehudasa i think maybe you missed something. The entry. http_method is assigned in function rgw_log_op

@stale
Copy link

stale bot commented Oct 18, 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 Oct 18, 2018
@stale
Copy link

stale bot commented Apr 22, 2019

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

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.

4 participants