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: ListMultipartUploads returns the real upload Owners #43715

Merged
merged 4 commits into from Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/rgw/rgw_rest.cc
Expand Up @@ -479,15 +479,15 @@ void dump_epoch_header(struct req_state *s, const char *name, real_time t)
return dump_header(s, name, std::string_view(buf, len));
}

void dump_time(struct req_state *s, const char *name, real_time *t)
void dump_time(struct req_state *s, const char *name, real_time t)
{
char buf[TIME_BUF_SIZE];
rgw_to_iso8601(*t, buf, sizeof(buf));
rgw_to_iso8601(t, buf, sizeof(buf));

s->formatter->dump_string(name, buf);
}

void dump_owner(struct req_state *s, const rgw_user& id, string& name,
void dump_owner(struct req_state *s, const rgw_user& id, const string& name,
const char *section)
{
if (!section)
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_rest.h
Expand Up @@ -703,8 +703,8 @@ extern void end_header(struct req_state *s,
bool force_no_error = false);
extern void dump_start(struct req_state *s);
extern void list_all_buckets_start(struct req_state *s);
extern void dump_owner(struct req_state *s, const rgw_user& id, std::string& name,
const char *section = NULL);
extern void dump_owner(struct req_state *s, const rgw_user& id,
const std::string& name, const char *section = NULL);
extern void dump_header(struct req_state* s,
const std::string_view& name,
const std::string_view& val);
Expand Down Expand Up @@ -801,7 +801,7 @@ extern void dump_range(struct req_state* s, uint64_t ofs, uint64_t end,
uint64_t total_size);
extern void dump_continue(struct req_state *s);
extern void list_all_buckets_end(struct req_state *s);
extern void dump_time(struct req_state *s, const char *name, real_time *t);
extern void dump_time(struct req_state *s, const char *name, real_time t);
extern std::string dump_time_to_str(const real_time& t);
extern void dump_bucket_from_state(struct req_state *s);
extern void dump_redirect(struct req_state *s, const std::string& redirect);
Expand Down
21 changes: 11 additions & 10 deletions src/rgw/rgw_rest_s3.cc
Expand Up @@ -92,7 +92,7 @@ void dump_bucket(struct req_state *s, rgw::sal::Bucket& obj)
{
s->formatter->open_object_section("Bucket");
s->formatter->dump_string("Name", obj.get_name());
dump_time(s, "CreationDate", &obj.get_creation_time());
dump_time(s, "CreationDate", obj.get_creation_time());
s->formatter->close_section();
}

Expand Down Expand Up @@ -1601,7 +1601,7 @@ void RGWListBucket_ObjStore_S3::send_versioned_response()
}
s->formatter->dump_string("VersionId", version_id);
s->formatter->dump_bool("IsLatest", iter->is_current());
dump_time(s, "LastModified", &iter->meta.mtime);
dump_time(s, "LastModified", iter->meta.mtime);
if (!iter->is_delete_marker()) {
s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
s->formatter->dump_int("Size", iter->meta.accounted_size);
Expand Down Expand Up @@ -1691,7 +1691,7 @@ void RGWListBucket_ObjStore_S3::send_response()
} else {
s->formatter->dump_string("Key", key.name);
}
dump_time(s, "LastModified", &iter->meta.mtime);
dump_time(s, "LastModified", iter->meta.mtime);
s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
s->formatter->dump_int("Size", iter->meta.accounted_size);
auto& storage_class = rgw_placement_rule::get_canonical_storage_class(iter->meta.storage_class);
Expand Down Expand Up @@ -1768,7 +1768,7 @@ void RGWListBucket_ObjStore_S3v2::send_versioned_response()
}
s->formatter->dump_string("VersionId", version_id);
s->formatter->dump_bool("IsLatest", iter->is_current());
dump_time(s, "LastModified", &iter->meta.mtime);
dump_time(s, "LastModified", iter->meta.mtime);
if (!iter->is_delete_marker()) {
s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
s->formatter->dump_int("Size", iter->meta.accounted_size);
Expand Down Expand Up @@ -1849,7 +1849,7 @@ void RGWListBucket_ObjStore_S3v2::send_response()
else {
s->formatter->dump_string("Key", key.name);
}
dump_time(s, "LastModified", &iter->meta.mtime);
dump_time(s, "LastModified", iter->meta.mtime);
s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str());
s->formatter->dump_int("Size", iter->meta.accounted_size);
auto& storage_class = rgw_placement_rule::get_canonical_storage_class(iter->meta.storage_class);
Expand Down Expand Up @@ -3320,7 +3320,7 @@ void RGWCopyObj_ObjStore_S3::send_response()
send_partial_response(0);

if (op_ret == 0) {
dump_time(s, "LastModified", &mtime);
dump_time(s, "LastModified", mtime);
if (!etag.empty()) {
s->formatter->dump_string("ETag", std::move(etag));
}
Expand Down Expand Up @@ -3846,7 +3846,7 @@ void RGWListMultipart_ObjStore_S3::send_response()

s->formatter->open_object_section("Part");

dump_time(s, "LastModified", &part->get_mtime());
dump_time(s, "LastModified", part->get_mtime());

s->formatter->dump_unsigned("PartNumber", part->get_num());
s->formatter->dump_format("ETag", "\"%s\"", part->get_etag().c_str());
Expand Down Expand Up @@ -3901,10 +3901,11 @@ void RGWListBucketMultiparts_ObjStore_S3::send_response()
s->formatter->dump_string("Key", upload->get_key());
}
s->formatter->dump_string("UploadId", upload->get_upload_id());
dump_owner(s, s->user->get_id(), s->user->get_display_name(), "Initiator");
dump_owner(s, s->user->get_id(), s->user->get_display_name());
const ACLOwner& owner = upload->get_owner();
dump_owner(s, owner.get_id(), owner.get_display_name(), "Initiator");
dump_owner(s, owner.get_id(), owner.get_display_name()); // Owner
s->formatter->dump_string("StorageClass", "STANDARD");
dump_time(s, "Initiated", &upload->get_mtime());
dump_time(s, "Initiated", upload->get_mtime());
s->formatter->close_section();
}
if (!common_prefixes.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rest_swift.cc
Expand Up @@ -401,7 +401,7 @@ void RGWListBucket_ObjStore_SWIFT::send_response()
}
s->formatter->dump_string("content_type", single_content_type);
}
dump_time(s, "last_modified", &iter->meta.mtime);
dump_time(s, "last_modified", iter->meta.mtime);
s->formatter->close_section();
}

Expand Down
8 changes: 6 additions & 2 deletions src/rgw/rgw_sal.h
Expand Up @@ -262,7 +262,10 @@ class Store {
virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
const std::string& tenant,
std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) = 0;
virtual std::unique_ptr<MultipartUpload> get_multipart_upload(Bucket* bucket, const std::string& oid, std::optional<std::string> upload_id=std::nullopt, ceph::real_time mtime=real_clock::now()) = 0;
virtual std::unique_ptr<MultipartUpload>
get_multipart_upload(Bucket* bucket, const std::string& oid,
std::optional<std::string> upload_id=std::nullopt,
ACLOwner owner={}, ceph::real_time mtime=real_clock::now()) = 0;
virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
optional_yield y,
std::unique_ptr<rgw::sal::Object> _head_obj,
Expand Down Expand Up @@ -818,7 +821,8 @@ class MultipartUpload {
virtual const std::string& get_meta() const = 0;
virtual const std::string& get_key() const = 0;
virtual const std::string& get_upload_id() const = 0;
virtual ceph::real_time& get_mtime() = 0;
virtual const ACLOwner& get_owner() const = 0;
virtual ceph::real_time get_mtime() const = 0;

std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() { return parts; }

Expand Down
5 changes: 4 additions & 1 deletion src/rgw/rgw_sal_dbstore.cc
Expand Up @@ -947,7 +947,10 @@ namespace rgw::sal {
return 0;
}

std::unique_ptr<MultipartUpload> DBStore::get_multipart_upload(Bucket* bucket, const std::string& oid, std::optional<std::string> upload_id, ceph::real_time mtime) {
std::unique_ptr<MultipartUpload>
DBStore::get_multipart_upload(Bucket* bucket, const std::string& oid,
std::optional<std::string> upload_id,
ACLOwner owner, ceph::real_time mtime) {
return nullptr;
}

Expand Down
5 changes: 4 additions & 1 deletion src/rgw/rgw_sal_dbstore.h
Expand Up @@ -540,7 +540,10 @@ class DBNotification : public Notification {
virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
const std::string& tenant,
vector<std::unique_ptr<RGWOIDCProvider>>& providers) override;
virtual std::unique_ptr<MultipartUpload> get_multipart_upload(Bucket* bucket, const std::string& oid, std::optional<std::string> upload_id, ceph::real_time mtime) override;
virtual std::unique_ptr<MultipartUpload>
get_multipart_upload(Bucket* bucket, const std::string& oid,
std::optional<std::string> upload_id=std::nullopt,
ACLOwner owner={}, ceph::real_time mtime=ceph::real_clock::now()) override;
virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
optional_yield y,
std::unique_ptr<rgw::sal::Object> _head_obj,
Expand Down
13 changes: 10 additions & 3 deletions src/rgw/rgw_sal_rados.cc
Expand Up @@ -777,7 +777,10 @@ int RadosBucket::list_multiparts(const DoutPrefixProvider *dpp,
if (!results.objs.empty()) {
for (const rgw_bucket_dir_entry& dentry : results.objs) {
rgw_obj_key key(dentry.key);
uploads.push_back(store->get_multipart_upload(this, key.name));
ACLOwner owner(rgw_user(dentry.meta.owner));
owner.set_name(dentry.meta.owner_display_name);
uploads.push_back(store->get_multipart_upload(
this, key.name, std::nullopt, std::move(owner)));
}
}
if (common_prefixes) {
Expand Down Expand Up @@ -1441,9 +1444,13 @@ int RadosStore::get_oidc_providers(const DoutPrefixProvider *dpp,
return 0;
}

std::unique_ptr<MultipartUpload> RadosStore::get_multipart_upload(Bucket* bucket, const std::string& oid, std::optional<std::string> upload_id, ceph::real_time mtime)
std::unique_ptr<MultipartUpload>
RadosStore::get_multipart_upload(Bucket* bucket, const std::string& oid,
std::optional<std::string> upload_id,
ACLOwner owner, ceph::real_time mtime)
{
return std::make_unique<RadosMultipartUpload>(this, bucket, oid, upload_id, mtime);
return std::make_unique<RadosMultipartUpload>(this, bucket, oid, upload_id,
std::move(owner), mtime);
}

std::unique_ptr<Writer> RadosStore::get_append_writer(const DoutPrefixProvider *dpp,
Expand Down
21 changes: 15 additions & 6 deletions src/rgw/rgw_sal_rados.h
Expand Up @@ -444,7 +444,10 @@ class RadosStore : public Store {
virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
const std::string& tenant,
std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) override;
virtual std::unique_ptr<MultipartUpload> get_multipart_upload(Bucket* bucket, const std::string& oid, std::optional<std::string> upload_id=std::nullopt, ceph::real_time mtime=real_clock::now()) override;
virtual std::unique_ptr<MultipartUpload>
get_multipart_upload(Bucket* bucket, const std::string& oid,
std::optional<std::string> upload_id=std::nullopt,
ACLOwner owner={}, ceph::real_time mtime=real_clock::now()) override;
virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
optional_yield y,
std::unique_ptr<rgw::sal::Object> _head_obj,
Expand Down Expand Up @@ -514,18 +517,24 @@ class RadosMultipartPart : public MultipartPart {
class RadosMultipartUpload : public MultipartUpload {
RadosStore* store;
RGWMPObj mp_obj;
ACLOwner owner;
ceph::real_time mtime;
rgw_placement_rule placement;
RGWObjManifest manifest;

public:
RadosMultipartUpload(RadosStore* _store, Bucket* _bucket, const std::string& oid, std::optional<std::string> upload_id, ceph::real_time _mtime) : MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), mtime(_mtime) {}
RadosMultipartUpload(RadosStore* _store, Bucket* _bucket, const std::string& oid,
std::optional<std::string> upload_id, ACLOwner owner,
ceph::real_time _mtime)
: MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id),
owner(owner), mtime(_mtime) {}
virtual ~RadosMultipartUpload() = default;

virtual const std::string& get_meta() const { return mp_obj.get_meta(); }
virtual const std::string& get_key() const { return mp_obj.get_key(); }
virtual const std::string& get_upload_id() const { return mp_obj.get_upload_id(); }
virtual ceph::real_time& get_mtime() { return mtime; }
virtual const std::string& get_meta() const override { return mp_obj.get_meta(); }
virtual const std::string& get_key() const override { return mp_obj.get_key(); }
virtual const std::string& get_upload_id() const override { return mp_obj.get_upload_id(); }
virtual const ACLOwner& get_owner() const override { return owner; }
virtual ceph::real_time get_mtime() const override { return mtime; }
virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() override;
virtual int init(const DoutPrefixProvider* dpp, optional_yield y, RGWObjectCtx* obj_ctx, ACLOwner& owner, rgw_placement_rule& dest_placement, rgw::sal::Attrs& attrs) override;
virtual int list_parts(const DoutPrefixProvider* dpp, CephContext* cct,
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sync_module_es_rest.cc
Expand Up @@ -342,7 +342,7 @@ class RGWMetadataSearch_ObjStore_S3 : public RGWMetadataSearchOp {
string instance = (!e.key.instance.empty() ? e.key.instance : "null");
s->formatter->dump_string("Instance", instance.c_str());
s->formatter->dump_int("VersionedEpoch", e.versioned_epoch);
dump_time(s, "LastModified", &e.meta.mtime);
dump_time(s, "LastModified", e.meta.mtime);
s->formatter->dump_int("Size", e.meta.size);
s->formatter->dump_format("ETag", "\"%s\"", e.meta.etag.c_str());
s->formatter->dump_string("ContentType", e.meta.content_type.c_str());
Expand Down