]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: `radosgw-admin object put ...` broken w/ versioned buckets 66673/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 9 Dec 2025 16:03:13 +0000 (11:03 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 17 Dec 2025 22:45:26 +0000 (17:45 -0500)
When this tool was used to write a new version of an object over an
existing version, instead of creating a new version it just overwrote
the latest version.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/rgw/rgw_data_access.cc

index 4cbbfeca68e497231a1079294f1931ac3b9d0c4a..d56155121d40584a343f2bc633122ac83200b6e6 100644 (file)
@@ -127,19 +127,26 @@ int RGWDataAccess::Object::put(bufferlist& data,
   std::string req_id = driver->zone_unique_id(driver->get_new_req_id());
 
   std::unique_ptr<rgw::sal::Writer> processor;
+
+  if (bucket_info.versioning_enabled() && obj->get_instance().empty()) {
+    obj->gen_rand_obj_instance_name();
+  }
+
   processor = driver->get_atomic_writer(dpp, y, obj.get(), owner,
                                       nullptr, olh_epoch, req_id);
 
   int ret = processor->prepare(y);
-  if (ret < 0)
+  if (ret < 0) {
     return ret;
+  }
 
   rgw::sal::DataProcessor *filter = processor.get();
 
   CompressorRef plugin;
   boost::optional<RGWPutObj_Compress> compressor;
 
-  const auto& compression_type = driver->get_compression_type(bucket_info.placement_rule);
+  const auto& compression_type =
+    driver->get_compression_type(bucket_info.placement_rule);
   if (compression_type != "none") {
     plugin = Compressor::create(driver->ctx(), compression_type);
     if (!plugin) {