]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/dbstore: Fixing s3 test 'test_bucket_delete_nonempty'
authorSoumya Koduri <skoduri@redhat.com>
Tue, 14 Dec 2021 06:07:14 +0000 (11:37 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 13 Jan 2022 11:52:11 +0000 (17:22 +0530)
if delete_children not set to 'true', delete bucket should
fail with ENOTEMPTY

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/rgw_sal.cc
src/rgw/rgw_sal_dbstore.cc
src/rgw/store/dbstore/sqlite/sqliteDB.cc

index e1eb3bd1e82b3954750e83381296f0032b980dae..efecca009e765878f927fdcb476ae07af96e648e 100644 (file)
@@ -92,6 +92,7 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d
     user->get_info().user_email = "tester@ceph.com";
     RGWAccessKey k1("0555b35654ad1656d804", "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==");
     user->get_info().access_keys["0555b35654ad1656d804"] = k1;
+    user->get_info().max_buckets = RGW_DEFAULT_MAX_BUCKETS;
 
     int r = user->store_user(dpp, null_yield, true);
     if (r < 0) {
index 2026c8e5b7ef42d96d72a8d69a9baca5713082ad..cddea7d8ab909a56ab9896635c83421df76124b8 100644 (file)
@@ -234,6 +234,32 @@ namespace rgw::sal {
 
     /* XXX: handle delete_children */
 
+    if (!delete_children) {
+      /* Check if there are any objects */
+      rgw::sal::Bucket::ListParams params;
+      params.list_versions = true;
+      params.allow_unordered = true;
+
+      rgw::sal::Bucket::ListResults results;
+
+      results.objs.clear();
+
+      ret = list(dpp, params, 2, results, null_yield);
+
+      if (ret < 0) {
+        ldpp_dout(dpp, 20) << __func__ << ": Bucket list objects returned " <<
+        ret << dendl;
+        return ret;
+      }
+
+      if (!results.objs.empty()) {
+        ret = -ENOTEMPTY;
+        ldpp_dout(dpp, -1) << __func__ << ": Bucket Not Empty.. returning " <<
+        ret << dendl;
+        return ret;
+      }
+    }
+
     ret = store->getDB()->remove_bucket(dpp, info);
 
     return ret;
index 417a3f78a9b66d6a9a0619ba4fb55e00ddee2b6a..67cd885adad2238b144ae544c2590941f68465ba 100644 (file)
 
 #define SQL_BIND_TEXT(dpp, stmt, index, str, sdb)                      \
   do {                                                         \
-    rc = sqlite3_bind_text(stmt, index, str, -1, SQLITE_TRANSIENT);    \
+    if (strcmp(str, "null") == 0) {          \
+      rc = sqlite3_bind_text(stmt, index, "", -1, SQLITE_TRANSIENT);   \
+    } else {                                                       \
+      rc = sqlite3_bind_text(stmt, index, str, -1, SQLITE_TRANSIENT);  \
+    }                                   \
     \
     if (rc != SQLITE_OK) {                                             \
       ldpp_dout(dpp, 0)<<"sqlite bind text failed for index("          \