Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: delete bucket does not remove .bucket.meta file #4641

Merged
merged 1 commit into from Jul 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/rgw/rgw_rados.cc
Expand Up @@ -3523,6 +3523,31 @@ int RGWRados::copy_obj_data(void *ctx,
return ret;
}

/**
* Check to see if the bucket metadata could be synced
* bucket: the bucket to check
* Returns false is the bucket is not synced
*/
bool RGWRados::is_syncing_bucket_meta(rgw_bucket& bucket)
{
/* region is not master region */
if (!region.is_master) {
return false;
}

/* single region and a single zone */
if (region_map.regions.size() == 1 && region.zones.size() == 1) {
return false;
}

/* zone is not master */
if (region.master_zone.compare(zone_name) != 0) {
return false;
}

return true;
}

/**
* Delete a bucket.
* bucket: the name of the bucket to delete
Expand Down Expand Up @@ -3562,6 +3587,16 @@ int RGWRados::delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_track
if (r < 0)
return r;

/* if the bucked is not synced we can remove the meta file */
if (!is_syncing_bucket_meta(bucket)) {
RGWObjVersionTracker objv_tracker;
string entry;
get_bucket_instance_entry(bucket, entry);
r= rgw_bucket_instance_remove_entry(this, entry, &objv_tracker);
if (r < 0) {
return r;
}
}
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/rgw/rgw_rados.h
Expand Up @@ -1590,6 +1590,11 @@ class RGWRados
*/
virtual int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker);

/**
* Check to see if the bucket metadata is synced
*/
bool is_syncing_bucket_meta(rgw_bucket& bucket);

int set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner);
int set_buckets_enabled(std::vector<rgw_bucket>& buckets, bool enabled);
int bucket_suspended(rgw_bucket& bucket, bool *suspended);
Expand Down