mirror of
https://github.com/ceph/ceph
synced 2025-02-22 02:27:29 +00:00
rgw: add a field to store generic user data in the bucket index,
that can populated/fetched via a configurable custom http header Fixes: http://tracker.ceph.com/issues/19644 Signed-off-by: Pavan Rallabhandi <prallabhandi@walmartlabs.com>
This commit is contained in:
parent
dad69a1592
commit
abca7a86c3
@ -61,6 +61,7 @@ void rgw_bucket_dir_entry_meta::dump(Formatter *f) const
|
||||
encode_json("owner_display_name", owner_display_name, f);
|
||||
encode_json("content_type", content_type, f);
|
||||
encode_json("accounted_size", accounted_size, f);
|
||||
encode_json("user_data", user_data, f);
|
||||
}
|
||||
|
||||
void rgw_bucket_dir_entry_meta::decode_json(JSONObj *obj) {
|
||||
@ -75,6 +76,7 @@ void rgw_bucket_dir_entry_meta::decode_json(JSONObj *obj) {
|
||||
JSONDecoder::decode_json("owner_display_name", owner_display_name, obj);
|
||||
JSONDecoder::decode_json("content_type", content_type, obj);
|
||||
JSONDecoder::decode_json("accounted_size", accounted_size, obj);
|
||||
JSONDecoder::decode_json("user_data", user_data, obj);
|
||||
}
|
||||
|
||||
void rgw_bucket_dir_entry::generate_test_instances(list<rgw_bucket_dir_entry*>& o)
|
||||
|
@ -95,12 +95,13 @@ struct rgw_bucket_dir_entry_meta {
|
||||
string owner_display_name;
|
||||
string content_type;
|
||||
uint64_t accounted_size;
|
||||
string user_data;
|
||||
|
||||
rgw_bucket_dir_entry_meta() :
|
||||
category(0), size(0), accounted_size(0) { }
|
||||
|
||||
void encode(bufferlist &bl) const {
|
||||
ENCODE_START(4, 3, bl);
|
||||
ENCODE_START(5, 3, bl);
|
||||
::encode(category, bl);
|
||||
::encode(size, bl);
|
||||
::encode(mtime, bl);
|
||||
@ -109,10 +110,11 @@ struct rgw_bucket_dir_entry_meta {
|
||||
::encode(owner_display_name, bl);
|
||||
::encode(content_type, bl);
|
||||
::encode(accounted_size, bl);
|
||||
::encode(user_data, bl);
|
||||
ENCODE_FINISH(bl);
|
||||
}
|
||||
void decode(bufferlist::iterator &bl) {
|
||||
DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
|
||||
DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, bl);
|
||||
::decode(category, bl);
|
||||
::decode(size, bl);
|
||||
::decode(mtime, bl);
|
||||
@ -125,6 +127,8 @@ struct rgw_bucket_dir_entry_meta {
|
||||
::decode(accounted_size, bl);
|
||||
else
|
||||
accounted_size = size;
|
||||
if (struct_v >= 5)
|
||||
::decode(user_data, bl);
|
||||
DECODE_FINISH(bl);
|
||||
}
|
||||
void dump(Formatter *f) const;
|
||||
|
@ -1716,3 +1716,5 @@ OPTION(event_tracing, OPT_BOOL, false) // true if LTTng-UST tracepoints should b
|
||||
OPTION(internal_safe_to_start_threads, OPT_BOOL, false)
|
||||
|
||||
OPTION(debug_deliberately_leak_memory, OPT_BOOL, false)
|
||||
|
||||
OPTION(rgw_swift_custom_header, OPT_STR, "") // option to enable swift custom headers
|
||||
|
@ -2667,7 +2667,7 @@ int RGWPutObjProcessor_Multipart::do_complete(size_t accounted_size,
|
||||
map<string, bufferlist>& attrs,
|
||||
real_time delete_at,
|
||||
const char *if_match,
|
||||
const char *if_nomatch)
|
||||
const char *if_nomatch, const string *user_data)
|
||||
{
|
||||
complete_writing_data();
|
||||
|
||||
@ -3221,7 +3221,8 @@ void RGWPutObj::execute()
|
||||
}
|
||||
|
||||
op_ret = processor->complete(s->obj_size, etag, &mtime, real_time(), attrs,
|
||||
(delete_at ? *delete_at : real_time()), if_match, if_nomatch);
|
||||
(delete_at ? *delete_at : real_time()), if_match, if_nomatch,
|
||||
(user_data.empty() ? nullptr : &user_data));
|
||||
|
||||
/* produce torrent */
|
||||
if (s->cct->_conf->rgw_torrent_flag && (ofs == torrent.get_data_len()))
|
||||
|
@ -926,6 +926,7 @@ protected:
|
||||
string version_id;
|
||||
bufferlist bl_aux;
|
||||
map<string, string> crypt_http_responses;
|
||||
string user_data;
|
||||
|
||||
boost::optional<ceph::real_time> delete_at;
|
||||
|
||||
|
@ -2356,9 +2356,9 @@ void RGWObjVersionTracker::generate_new_write_ver(CephContext *cct)
|
||||
int RGWPutObjProcessor::complete(size_t accounted_size, const string& etag,
|
||||
real_time *mtime, real_time set_mtime,
|
||||
map<string, bufferlist>& attrs, real_time delete_at,
|
||||
const char *if_match, const char *if_nomatch)
|
||||
const char *if_match, const char *if_nomatch, const string *user_data)
|
||||
{
|
||||
int r = do_complete(accounted_size, etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch);
|
||||
int r = do_complete(accounted_size, etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch, user_data);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -2700,7 +2700,7 @@ int RGWPutObjProcessor_Atomic::do_complete(size_t accounted_size, const string&
|
||||
map<string, bufferlist>& attrs,
|
||||
real_time delete_at,
|
||||
const char *if_match,
|
||||
const char *if_nomatch) {
|
||||
const char *if_nomatch, const string *user_data) {
|
||||
int r = complete_writing_data();
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -2725,6 +2725,8 @@ int RGWPutObjProcessor_Atomic::do_complete(size_t accounted_size, const string&
|
||||
obj_op.meta.flags = PUT_OBJ_CREATE;
|
||||
obj_op.meta.olh_epoch = olh_epoch;
|
||||
obj_op.meta.delete_at = delete_at;
|
||||
obj_op.meta.user_data = user_data;
|
||||
|
||||
r = obj_op.write_meta(obj_len, accounted_size, attrs);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
@ -6504,7 +6506,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si
|
||||
|
||||
r = index_op->complete(poolid, epoch, size, accounted_size,
|
||||
meta.set_mtime, etag, content_type, &acl_bl,
|
||||
meta.category, meta.remove_objs);
|
||||
meta.category, meta.remove_objs, meta.user_data);
|
||||
if (r < 0)
|
||||
goto done_cancel;
|
||||
|
||||
@ -9460,7 +9462,7 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch,
|
||||
const string& content_type,
|
||||
bufferlist *acl_bl,
|
||||
RGWObjCategory category,
|
||||
list<rgw_obj_index_key> *remove_objs)
|
||||
list<rgw_obj_index_key> *remove_objs, const string *user_data)
|
||||
{
|
||||
if (blind) {
|
||||
return 0;
|
||||
@ -9479,6 +9481,9 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch,
|
||||
ent.meta.accounted_size = accounted_size;
|
||||
ent.meta.mtime = ut;
|
||||
ent.meta.etag = etag;
|
||||
if (user_data)
|
||||
ent.meta.user_data = *user_data;
|
||||
|
||||
ACLOwner owner;
|
||||
if (acl_bl && acl_bl->length()) {
|
||||
int ret = store->decode_policy(*acl_bl, &owner);
|
||||
|
@ -2740,10 +2740,11 @@ public:
|
||||
uint64_t olh_epoch;
|
||||
ceph::real_time delete_at;
|
||||
bool canceled;
|
||||
const string *user_data;
|
||||
|
||||
MetaParams() : mtime(NULL), rmattrs(NULL), data(NULL), manifest(NULL), ptag(NULL),
|
||||
remove_objs(NULL), category(RGW_OBJ_CATEGORY_MAIN), flags(0),
|
||||
if_match(NULL), if_nomatch(NULL), olh_epoch(0), canceled(false) {}
|
||||
if_match(NULL), if_nomatch(NULL), olh_epoch(0), canceled(false), user_data(nullptr) {}
|
||||
} meta;
|
||||
|
||||
explicit Write(RGWRados::Object *_target) : target(_target) {}
|
||||
@ -2876,7 +2877,7 @@ public:
|
||||
uint64_t accounted_size, ceph::real_time& ut,
|
||||
const string& etag, const string& content_type,
|
||||
bufferlist *acl_bl, RGWObjCategory category,
|
||||
list<rgw_obj_index_key> *remove_objs);
|
||||
list<rgw_obj_index_key> *remove_objs, const string *user_data = nullptr);
|
||||
int complete_del(int64_t poolid, uint64_t epoch,
|
||||
ceph::real_time& removed_mtime, /* mtime of removed object */
|
||||
list<rgw_obj_index_key> *remove_objs);
|
||||
@ -3655,7 +3656,7 @@ protected:
|
||||
virtual int do_complete(size_t accounted_size, const string& etag,
|
||||
ceph::real_time *mtime, ceph::real_time set_mtime,
|
||||
map<string, bufferlist>& attrs, ceph::real_time delete_at,
|
||||
const char *if_match, const char *if_nomatch) = 0;
|
||||
const char *if_match, const char *if_nomatch, const string *user_data) = 0;
|
||||
|
||||
public:
|
||||
RGWPutObjProcessor(RGWObjectCtx& _obj_ctx, RGWBucketInfo& _bi) : store(NULL),
|
||||
@ -3672,7 +3673,7 @@ public:
|
||||
int complete(size_t accounted_size, const string& etag,
|
||||
ceph::real_time *mtime, ceph::real_time set_mtime,
|
||||
map<string, bufferlist>& attrs, ceph::real_time delete_at,
|
||||
const char *if_match = NULL, const char *if_nomatch = NULL);
|
||||
const char *if_match = NULL, const char *if_nomatch = NULL, const string *user_data = nullptr);
|
||||
|
||||
CephContext *ctx();
|
||||
|
||||
@ -3750,7 +3751,7 @@ protected:
|
||||
int do_complete(size_t accounted_size, const string& etag,
|
||||
ceph::real_time *mtime, ceph::real_time set_mtime,
|
||||
map<string, bufferlist>& attrs, ceph::real_time delete_at,
|
||||
const char *if_match, const char *if_nomatch) override;
|
||||
const char *if_match, const char *if_nomatch, const string *user_data) override;
|
||||
|
||||
int prepare_next_part(off_t ofs);
|
||||
int complete_parts();
|
||||
@ -3865,7 +3866,7 @@ protected:
|
||||
int do_complete(size_t accounted_size, const string& etag,
|
||||
ceph::real_time *mtime, ceph::real_time set_mtime,
|
||||
map<string, bufferlist>& attrs, ceph::real_time delete_at,
|
||||
const char *if_match, const char *if_nomatch) override;
|
||||
const char *if_match, const char *if_nomatch, const string *user_data) override;
|
||||
public:
|
||||
bool immutable_head() { return true; }
|
||||
RGWPutObjProcessor_Multipart(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, uint64_t _p, req_state *_s) :
|
||||
|
@ -306,6 +306,8 @@ void RGWListBucket_ObjStore_SWIFT::send_response()
|
||||
s->formatter->dump_string("name", key.name);
|
||||
s->formatter->dump_string("hash", iter->meta.etag);
|
||||
s->formatter->dump_int("bytes", iter->meta.accounted_size);
|
||||
if (!iter->meta.user_data.empty())
|
||||
s->formatter->dump_string("user_custom_data", iter->meta.user_data);
|
||||
string single_content_type = iter->meta.content_type;
|
||||
if (iter->meta.content_type.size()) {
|
||||
// content type might hold multiple values, just dump the last one
|
||||
@ -758,6 +760,13 @@ int RGWPutObj_ObjStore_SWIFT::get_params()
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!s->cct->_conf->rgw_swift_custom_header.empty()) {
|
||||
string custom_header = s->cct->_conf->rgw_swift_custom_header;
|
||||
if (s->info.env->exists(custom_header.c_str())) {
|
||||
user_data = s->info.env->get(custom_header.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
dlo_manifest = s->info.env->get("HTTP_X_OBJECT_MANIFEST");
|
||||
bool exists;
|
||||
string multipart_manifest = s->info.args.get("multipart-manifest", &exists);
|
||||
|
Loading…
Reference in New Issue
Block a user