In openstack swift, it also support the feature to cancel the object expiration,
which could be found at last point in
https://docs.openstack.org/user-guide/cli-swift-set-object-expiration.html. we
can remove the object expiration by set 'X-Remove-Delete-At:'.
This patch also could fix the bug that when we set the object expiration and
then upload the same object to the container again. The previous object expiration
also works, which is not compatible with the openstack swift.
Fixes: http://tracker.ceph.com/issues/19074
Signed-off-by: Jing Wenjun <jingwenjun@cmss.chinamobile.com>
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));
return false;
}
- if (delete_at <= ceph_clock_now()) {
+ if (delete_at <= ceph_clock_now() && !delete_at.is_zero()) {
return true;
}
}
}
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()))
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()));
}
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,
string version_id;
bufferlist bl_aux;
- ceph::real_time delete_at;
+ boost::optional<ceph::real_time> delete_at;
public:
RGWPutObj() : ofs(0),
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),
protected:
RGWAccessControlPolicy policy;
string placement_rule;
- ceph::real_time delete_at;
+ boost::optional<ceph::real_time> delete_at;
const char *dlo_manifest;
public:
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();
}
} /* 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 */
if (params.expiration_time != delete_at) {
return -ERR_PRECONDITION_FAILED;
}
+ } else {
+ return -ERR_PRECONDITION_FAILED;
}
}
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;
}
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;
return -EINVAL;
}
- *delete_at = delat_proposal;
+ delete_at = delat_proposal;
return 0;
}
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;
}
/* 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;
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"
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;