RGWSI_BucketIndex *bi{nullptr};
} svc;
- RGWBucketInstanceMetadataHandler() {}
+ rgw::sal::Store* store;
+
+ RGWBucketInstanceMetadataHandler(rgw::sal::Store* store)
+ : store(store) {}
void init(RGWSI_Zone *zone_svc,
RGWSI_Bucket *bucket_svc,
return ret;
}
+ /* update lifecyle policy */
+ {
+ std::unique_ptr<rgw::sal::Bucket> bucket;
+ ret = bihandler->store->get_bucket(nullptr, bci.info, &bucket);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << __func__ << " failed to get_bucket(...) for "
+ << bci.info.bucket.name
+ << dendl;
+ return ret;
+ }
+
+ auto lc = bihandler->store->get_rgwlc();
+
+ auto lc_it = bci.attrs.find(RGW_ATTR_LC);
+ if (lc_it != bci.attrs.end()) {
+ ldpp_dout(dpp, 20) << "set lc config for " << bci.info.bucket.name << dendl;
+ ret = lc->set_bucket_config(bucket.get(), bci.attrs, nullptr);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << __func__ << " failed to set lc config for "
+ << bci.info.bucket.name
+ << dendl;
+ return ret;
+ }
+
+ } else {
+ ldpp_dout(dpp, 20) << "remove lc config for " << bci.info.bucket.name << dendl;
+ ret = lc->remove_bucket_config(bucket.get(), bci.attrs);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << __func__ << " failed to remove lc config for "
+ << bci.info.bucket.name
+ << dendl;
+ return ret;
+ }
+ }
+ } /* update lc */
+
return STATUS_APPLIED;
}
class RGWArchiveBucketInstanceMetadataHandler : public RGWBucketInstanceMetadataHandler {
public:
- RGWArchiveBucketInstanceMetadataHandler() {}
+ RGWArchiveBucketInstanceMetadataHandler(rgw::sal::Store* store)
+ : RGWBucketInstanceMetadataHandler(store) {}
+
+ // N.B. replication of lifecycle policy relies on logic in RGWBucketInstanceMetadataHandler::do_put(...), override with caution
int do_remove(RGWSI_MetaBackend_Handler::Op *op, string& entry, RGWObjVersionTracker& objv_tracker, optional_yield y, const DoutPrefixProvider *dpp) override {
ldpp_dout(dpp, 0) << "SKIP: bucket instance removal is not allowed on archive zone: bucket.instance:" << entry << dendl;
return handler->bucket_imports_data();
}
-RGWBucketMetadataHandlerBase *RGWBucketMetaHandlerAllocator::alloc()
+RGWBucketMetadataHandlerBase* RGWBucketMetaHandlerAllocator::alloc()
{
return new RGWBucketMetadataHandler();
}
-RGWBucketInstanceMetadataHandlerBase *RGWBucketInstanceMetaHandlerAllocator::alloc()
+RGWBucketInstanceMetadataHandlerBase* RGWBucketInstanceMetaHandlerAllocator::alloc(rgw::sal::Store* store)
{
- return new RGWBucketInstanceMetadataHandler();
+ return new RGWBucketInstanceMetadataHandler(store);
}
-RGWBucketMetadataHandlerBase *RGWArchiveBucketMetaHandlerAllocator::alloc()
+RGWBucketMetadataHandlerBase* RGWArchiveBucketMetaHandlerAllocator::alloc()
{
return new RGWArchiveBucketMetadataHandler();
}
-RGWBucketInstanceMetadataHandlerBase *RGWArchiveBucketInstanceMetaHandlerAllocator::alloc()
+RGWBucketInstanceMetadataHandlerBase* RGWArchiveBucketInstanceMetaHandlerAllocator::alloc(rgw::sal::Store* store)
{
- return new RGWArchiveBucketInstanceMetadataHandler();
+ return new RGWArchiveBucketInstanceMetadataHandler(store);
}
class RGWBucketInstanceMetaHandlerAllocator {
public:
- static RGWBucketInstanceMetadataHandlerBase *alloc();
+ static RGWBucketInstanceMetadataHandlerBase *alloc(rgw::sal::Store* store);
};
class RGWArchiveBucketMetaHandlerAllocator {
class RGWArchiveBucketInstanceMetaHandlerAllocator {
public:
- static RGWBucketInstanceMetadataHandlerBase *alloc();
+ static RGWBucketInstanceMetadataHandlerBase *alloc(rgw::sal::Store* store);
};
extern int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::Store* store, rgw::sal::Bucket* bucket, rgw_obj_key& key);
static constexpr uint32_t lock_duration = 30;
RGWDataSyncCtx *sc;
RGWDataSyncEnv *sync_env;
- rgw::sal::RadosStore* store;
+ rgw::sal::RadosStore* store; // RGWDataSyncEnv also has a pointer to store
const rgw_pool& pool;
const uint32_t num_shards;
RGWMetadataHandler *alloc_bucket_meta_handler() override {
return RGWArchiveBucketMetaHandlerAllocator::alloc();
}
- RGWBucketInstanceMetadataHandlerBase *alloc_bucket_instance_meta_handler() override {
- return RGWArchiveBucketInstanceMetaHandlerAllocator::alloc();
+ RGWBucketInstanceMetadataHandlerBase *alloc_bucket_instance_meta_handler(rgw::sal::Store* store) override {
+ return RGWArchiveBucketInstanceMetaHandlerAllocator::alloc(store);
}
};
const rgw::sal::Attrs& bucket_attrs,
RGWLifecycleConfiguration *config)
{
+ int ret{0};
rgw::sal::Attrs attrs = bucket_attrs;
- bufferlist lc_bl;
- config->encode(lc_bl);
-
- attrs[RGW_ATTR_LC] = std::move(lc_bl);
-
- int ret =
- bucket->merge_and_store_attrs(this, attrs, null_yield);
- if (ret < 0)
- return ret;
+ if (config) {
+ /* if no RGWLifecycleconfiguration provided, it means
+ * RGW_ATTR_LC is already valid and present */
+ bufferlist lc_bl;
+ config->encode(lc_bl);
+ attrs[RGW_ATTR_LC] = std::move(lc_bl);
+
+ ret =
+ bucket->merge_and_store_attrs(this, attrs, null_yield);
+ if (ret < 0) {
+ return ret;
+ }
+ }
rgw_bucket& b = bucket->get_key();