radosgw-admin: pull 'log show' owner+bucket from first entry

Don't rely on the bucketinfo object for this, as it may be deleted.  Having
it there most of the time but not always is going to mean breakage for
users.

Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
Sage Weil 2011-09-29 16:33:32 -07:00
parent 560f90c57f
commit aa7c5c5fd9

View File

@ -1148,19 +1148,14 @@ int main(int argc, char **argv)
formatter->reset();
formatter->open_object_section("log");
// peek at first entry to get bucket metadata
bufferlist::iterator first_iter = iter;
if (!first_iter.end()) {
::decode(entry, first_iter);
int ret = rgw_get_bucket_info_id(entry.bucket_id, bucket_info);
if (ret >= 0) {
formatter->dump_string("bucket", bucket_info.bucket.name.c_str());
formatter->dump_string("pool", bucket_info.bucket.pool.c_str());
formatter->dump_string("bucket_owner", bucket_info.owner.c_str());
} else {
cerr << "could not retrieve bucket info for bucket_id=" << bucket_id << std::endl;
}
formatter->dump_int("bucket_id", entry.bucket_id);
formatter->dump_string("owner", entry.owner);
formatter->dump_string("bucket", entry.bucket);
}
formatter->open_array_section("log_entries");