From: Soumya Koduri Date: Tue, 14 Dec 2021 06:07:14 +0000 (+0530) Subject: rgw/dbstore: Fixing s3 test 'test_bucket_delete_nonempty' X-Git-Tag: v17.1.0~47^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7b5527ba2ba4c94388136b1012d881691d7677d6;p=ceph.git rgw/dbstore: Fixing s3 test 'test_bucket_delete_nonempty' if delete_children not set to 'true', delete bucket should fail with ENOTEMPTY Signed-off-by: Soumya Koduri --- diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index e1eb3bd1e82b..efecca009e76 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -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) { diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 2026c8e5b7ef..cddea7d8ab90 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -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; diff --git a/src/rgw/store/dbstore/sqlite/sqliteDB.cc b/src/rgw/store/dbstore/sqlite/sqliteDB.cc index 417a3f78a9b6..67cd885adad2 100644 --- a/src/rgw/store/dbstore/sqlite/sqliteDB.cc +++ b/src/rgw/store/dbstore/sqlite/sqliteDB.cc @@ -40,7 +40,11 @@ #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(" \