Skip to content

Commit e03f5ca

Browse files
committed
RGW\logging: convert s3_filter to key_filter
Signed-off-by: Ali Masarwa <[email protected]>
1 parent ca9e0f4 commit e03f5ca

File tree

4 files changed

+35
-54
lines changed

4 files changed

+35
-54
lines changed

doc/radosgw/s3/bucketops.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -758,18 +758,6 @@ Parameters are XML encoded in the body of the request, in the following format:
758758
<Value></Value>
759759
</FilterRule>
760760
</S3Key>
761-
<S3Metadata>
762-
<FilterRule>
763-
<Name></Name>
764-
<Value></Value>
765-
</FilterRule>
766-
</S3Metadata>
767-
<S3Tags>
768-
<FilterRule>
769-
<Name></Name>
770-
<Value></Value>
771-
</FilterRule>
772-
</S3Tags>
773761
</Filter>
774762
</LoggingEnabled>
775763
</BucketLoggingStatus>
@@ -908,18 +896,6 @@ Response is XML encoded in the body of the request, in the following format:
908896
<Value></Value>
909897
</FilterRule>
910898
</S3Key>
911-
<S3Metadata>
912-
<FilterRule>
913-
<Name></Name>
914-
<Value></Value>
915-
</FilterRule>
916-
</S3Metadata>
917-
<S3Tags>
918-
<FilterRule>
919-
<Name></Name>
920-
<Value></Value>
921-
</FilterRule>
922-
</S3Tags>
923899
</Filter>
924900
</LoggingEnabled>
925901
</BucketLoggingStatus>

examples/rgw/boto3/service-2.sdk-extras.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@
289289
"documentation":"indicates how many records to batch in memory before writing to the object. if set to zero, records are written syncronously to the object. if <code>ObjectRollTime</code>e is reached, the batch of records will be written to the object regardless of the number of records. </p>"
290290
},
291291
"Filter":{
292-
"shape":"NotificationConfigurationFilter",
293-
"documentation":"<p>A filter for all log object. Types of filter for the object by its: attributes, tags and key (prefix, suffix and regex).</p>"
292+
"shape":"LoggingConfigurationFilter",
293+
"documentation":"<p>A filter for all log object. Filter for the object by its key (prefix, suffix and regex).</p>"
294294
}
295295
},
296296
"documentation":"<p>Describes where logs are stored the prefix assigned to all log object keys for a bucket, and their format. also, the level the delivery guarantee of the records.</p>"
@@ -344,6 +344,18 @@
344344
"Standard",
345345
"Journal"
346346
]
347+
},
348+
"LoggingConfigurationFilter":{
349+
"type":"structure",
350+
"members":{
351+
"Key":{
352+
"shape":"S3KeyFilter",
353+
"documentation":"<p/>",
354+
"locationName":"S3Key"
355+
}
356+
},
357+
"documentation":"<p>A filter for all log object. Filter for the object by its key (prefix, suffix and regex).</p>",
358+
"locationName":"Filter"
347359
}
348360
},
349361
"documentation":"<p/>"

src/rgw/rgw_bucket_logging.cc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ bool configuration::decode_xml(XMLObj* obj) {
3131
logging_type = LoggingType::Standard;
3232
} else if (type == "Journal") {
3333
logging_type = LoggingType::Journal;
34-
RGWXMLDecoder::decode_xml("Filter", s3_filter, o);
34+
if (iter = o->find("Filter"); XMLObj* const filter_o = iter.get_next()) {
35+
RGWXMLDecoder::decode_xml("S3Key", key_filter, filter_o);
36+
}
3537
} else {
3638
// we don't allow for type "Any" in the configuration
3739
throw RGWXMLDecoder::err("invalid bucket logging record type: '" + type + "'");
@@ -74,8 +76,10 @@ void configuration::dump_xml(Formatter *f) const {
7476
break;
7577
case LoggingType::Journal:
7678
::encode_xml("LoggingType", "Journal", f);
77-
if (s3_filter.has_content()) {
78-
::encode_xml("Filter", s3_filter, f);
79+
if (key_filter.has_content()) {
80+
f->open_object_section("Filter");
81+
::encode_xml("S3Key", key_filter, f);
82+
f->close_section(); // Filter
7983
}
8084
break;
8185
case LoggingType::Any:
@@ -122,8 +126,9 @@ void configuration::dump(Formatter *f) const {
122126
break;
123127
case LoggingType::Journal:
124128
encode_json("loggingType", "Journal", f);
125-
if (s3_filter.has_content()) {
126-
encode_json("Filter", s3_filter, f);
129+
if (key_filter.has_content()) {
130+
Formatter::ObjectSection s(*f, "Filter");
131+
encode_json("S3Key", key_filter, f);
127132
}
128133
break;
129134
case LoggingType::Any:
@@ -533,8 +538,8 @@ int log_record(rgw::sal::Driver* driver,
533538
if (type != LoggingType::Any && configuration.logging_type != type) {
534539
return 0;
535540
}
536-
if (configuration.s3_filter.has_content()) {
537-
if (!match(configuration.s3_filter, obj)) {
541+
if (configuration.key_filter.has_content()) {
542+
if (!match(configuration.key_filter, obj->get_name())) {
538543
return 0;
539544
}
540545
}

src/rgw/rgw_bucket_logging.h

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,12 @@ namespace rgw::bucketlogging {
5050
<ObjectRollTime>integer</ObjectRollTime> <!-- Ceph extension -->
5151
<RecordsBatchSize>integer</RecordsBatchSize> <!-- Ceph extension -->
5252
<Filter>
53-
<S3Key>
54-
<FilterRule>
55-
<Name>suffix/prefix/regex</Name>
56-
<Value></Value>
57-
</FilterRule>
58-
</S3Key>
59-
<S3Metadata>
60-
<FilterRule>
61-
<Name></Name>
62-
<Value></Value>
63-
</FilterRule>
64-
</S3Metadata>
65-
<S3Tags>
66-
<FilterRule>
67-
<Name></Name>
68-
<Value></Value>
69-
</FilterRule>
70-
</S3Tags>
53+
<S3Key>
54+
<FilterRule>
55+
<Name>suffix/prefix/regex</Name>
56+
<Value></Value>
57+
</FilterRule>
58+
</S3Key>
7159
</Filter>
7260
</LoggingEnabled>
7361
</BucketLoggingStatus>
@@ -99,7 +87,7 @@ struct configuration {
9987
PartitionDateSource date_source = PartitionDateSource::DeliveryTime;
10088
// EventTime: use only year, month, and day. The hour, minutes and seconds are set to 00 in the key
10189
// DeliveryTime: the time the log object was created
102-
rgw_s3_filter s3_filter;
90+
rgw_s3_key_filter key_filter;
10391
bool decode_xml(XMLObj *obj);
10492
void dump_xml(Formatter *f) const;
10593
void dump(Formatter *f) const; // json
@@ -115,7 +103,7 @@ struct configuration {
115103
encode(records_batch_size, bl);
116104
encode(static_cast<int>(date_source), bl);
117105
if (logging_type == LoggingType::Journal) {
118-
encode(s3_filter, bl);
106+
encode(key_filter, bl);
119107
}
120108
ENCODE_FINISH(bl);
121109
}
@@ -134,7 +122,7 @@ struct configuration {
134122
decode(type, bl);
135123
date_source = static_cast<PartitionDateSource>(type);
136124
if (logging_type == LoggingType::Journal) {
137-
decode(s3_filter, bl);
125+
decode(key_filter, bl);
138126
}
139127
DECODE_FINISH(bl);
140128
}

0 commit comments

Comments
 (0)