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

kraken: rgw: add the remove-x-delete feature to cancel swift object expiration #14522

Merged
merged 1 commit into from Jul 7, 2017
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
4 changes: 2 additions & 2 deletions src/rgw/rgw_file.cc
Expand Up @@ -1069,8 +1069,8 @@ namespace rgw {
emplace_attr(RGW_ATTR_SLO_UINDICATOR, std::move(slo_userindicator_bl));
}

op_ret = processor->complete(s->obj_size, etag, &mtime, real_time(), attrs, delete_at,
if_match, if_nomatch);
op_ret = processor->complete(s->obj_size, etag, &mtime, real_time(), attrs,
(delete_at ? *delete_at : real_time()), if_match, if_nomatch);
if (! op_ret) {
/* update stats */
rgw_fh->set_mtime(real_clock::to_timespec(mtime));
Expand Down
9 changes: 5 additions & 4 deletions src/rgw/rgw_op.cc
Expand Up @@ -1318,7 +1318,7 @@ static bool object_is_expired(map<string, bufferlist>& attrs) {
return false;
}

if (delete_at <= ceph_clock_now()) {
if (delete_at <= ceph_clock_now() && !delete_at.is_zero()) {
return true;
}
}
Expand Down Expand Up @@ -3170,7 +3170,7 @@ void RGWPutObj::execute()
}

op_ret = processor->complete(s->obj_size, etag, &mtime, real_time(), attrs,
delete_at, if_match, if_nomatch);
(delete_at ? *delete_at : real_time()), if_match, if_nomatch);

/* produce torrent */
if (s->cct->_conf->rgw_torrent_flag && (ofs == torrent.get_data_len()))
Expand Down Expand Up @@ -3341,7 +3341,8 @@ void RGWPostObj::execute()
emplace_attr(RGW_ATTR_COMPRESSION, std::move(tmp));
}

op_ret = processor.complete(s->obj_size, etag, NULL, real_time(), attrs, delete_at);
op_ret = processor.complete(s->obj_size, etag, NULL, real_time(), attrs,
(delete_at ? *delete_at : real_time()));
}


Expand Down Expand Up @@ -4005,7 +4006,7 @@ void RGWCopyObj::execute()
copy_if_newer,
attrs, RGW_OBJ_CATEGORY_MAIN,
olh_epoch,
delete_at,
(delete_at ? *delete_at : real_time()),
(version_id.empty() ? NULL : &version_id),
&s->req_id, /* use req_id as tag */
&etag,
Expand Down
16 changes: 8 additions & 8 deletions src/rgw/rgw_op.h
Expand Up @@ -720,7 +720,7 @@ class RGWPutObj : public RGWOp {
string version_id;
bufferlist bl_aux;

ceph::real_time delete_at;
boost::optional<ceph::real_time> delete_at;

public:
RGWPutObj() : ofs(0),
Expand Down Expand Up @@ -798,7 +798,7 @@ class RGWPostObj : public RGWOp {
string content_type;
RGWAccessControlPolicy policy;
map<string, bufferlist> attrs;
ceph::real_time delete_at;
boost::optional<ceph::real_time> delete_at;

public:
RGWPostObj() : min_len(0),
Expand Down Expand Up @@ -908,7 +908,7 @@ class RGWPutMetadataObject : public RGWOp {
protected:
RGWAccessControlPolicy policy;
string placement_rule;
ceph::real_time delete_at;
boost::optional<ceph::real_time> delete_at;
const char *dlo_manifest;

public:
Expand Down Expand Up @@ -998,7 +998,7 @@ class RGWCopyObj : public RGWOp {
string version_id;
uint64_t olh_epoch;

ceph::real_time delete_at;
boost::optional<ceph::real_time> delete_at;
bool copy_if_newer;

int init_common();
Expand Down Expand Up @@ -1701,15 +1701,15 @@ static inline void rgw_get_request_metadata(CephContext *cct,
}
} /* rgw_get_request_metadata */

static inline void encode_delete_at_attr(ceph::real_time delete_at,
static inline void encode_delete_at_attr(boost::optional<ceph::real_time> delete_at,
map<string, bufferlist>& attrs)
{
if (real_clock::is_zero(delete_at)) {
if (delete_at == boost::none) {
return;
}
}

bufferlist delatbl;
::encode(delete_at, delatbl);
::encode(*delete_at, delatbl);
attrs[RGW_ATTR_DELETE_AT] = delatbl;
} /* encode_delete_at_attr */

Expand Down
2 changes: 2 additions & 0 deletions src/rgw/rgw_rados.cc
Expand Up @@ -8250,6 +8250,8 @@ int RGWRados::Object::Delete::delete_obj()
if (params.expiration_time != delete_at) {
return -ERR_PRECONDITION_FAILED;
}
} else {
return -ERR_PRECONDITION_FAILED;
}
}

Expand Down
18 changes: 12 additions & 6 deletions src/rgw/rgw_rest_swift.cc
Expand Up @@ -663,7 +663,7 @@ void RGWDeleteBucket_ObjStore_SWIFT::send_response()
rgw_flush_formatter_and_reset(s, s->formatter);
}

static int get_delete_at_param(req_state *s, real_time *delete_at)
static int get_delete_at_param(req_state *s, boost::optional<real_time> &delete_at)
{
/* Handle Swift object expiration. */
real_time delat_proposal;
Expand All @@ -678,6 +678,10 @@ static int get_delete_at_param(req_state *s, real_time *delete_at)
}

if (x_delete.empty()) {
delete_at = boost::none;
if (s->info.env->exists("HTTP_X_REMOVE_DELETE_AT")) {
delete_at = boost::in_place(real_time());
}
return 0;
}
string err;
Expand All @@ -692,7 +696,7 @@ static int get_delete_at_param(req_state *s, real_time *delete_at)
return -EINVAL;
}

*delete_at = delat_proposal;
delete_at = delat_proposal;

return 0;
}
Expand Down Expand Up @@ -746,7 +750,7 @@ int RGWPutObj_ObjStore_SWIFT::get_params()

policy.create_default(s->user->user_id, s->user->display_name);

int r = get_delete_at_param(s, &delete_at);
int r = get_delete_at_param(s, delete_at);
if (r < 0) {
ldout(s->cct, 5) << "ERROR: failed to get Delete-At param" << dendl;
return r;
Expand Down Expand Up @@ -919,7 +923,7 @@ int RGWPutMetadataObject_ObjStore_SWIFT::get_params()
}

/* Handle Swift object expiration. */
int r = get_delete_at_param(s, &delete_at);
int r = get_delete_at_param(s, delete_at);
if (r < 0) {
ldout(s->cct, 5) << "ERROR: failed to get Delete-At param" << dendl;
return r;
Expand Down Expand Up @@ -1118,7 +1122,9 @@ static void dump_object_metadata(struct req_state * const s,
utime_t delete_at;
try {
::decode(delete_at, iter->second);
dump_header(s, "X-Delete-At", delete_at.sec());
if (!delete_at.is_zero()) {
dump_header(s, "X-Delete-At", delete_at.sec());
}
} catch (buffer::error& err) {
ldout(s->cct, 0) << "ERROR: cannot decode object's " RGW_ATTR_DELETE_AT
" attr, ignoring"
Expand Down Expand Up @@ -1155,7 +1161,7 @@ int RGWCopyObj_ObjStore_SWIFT::get_params()
attrs_mod = RGWRados::ATTRSMOD_MERGE;
}

int r = get_delete_at_param(s, &delete_at);
int r = get_delete_at_param(s, delete_at);
if (r < 0) {
ldout(s->cct, 5) << "ERROR: failed to get Delete-At param" << dendl;
return r;
Expand Down