if (strcmp(cmd, "list") == 0)
return OPT_ZONE_PLACEMENT_LIST;
} else if (strcmp(prev_cmd, "zone") == 0) {
- if (strcmp(cmd, "delete") == 0)
+ if (match_str(cmd, "rm", "delete"))
return OPT_ZONE_DELETE;
if (strcmp(cmd, "create") == 0)
return OPT_ZONE_CREATE;
shards_behind.insert(shard_id);
}
}
- if (shards_behind.empty()) {
- out << indented{width} << "bucket is caught up with source\n";
- } else {
+ if (!shards_behind.empty()) {
out << indented{width} << "bucket is behind on " << shards_behind.size() << " shards\n";
out << indented{width} << "behind shards: [" << shards_behind << "]\n" ;
+ } else if (!num_full) {
+ out << indented{width} << "bucket is caught up with source\n";
}
return 0;
}
string sub_dest_bucket;
string sub_push_endpoint;
string event_id;
- set<string, ltstr_nocase> event_types;
+ rgw::notify::EventTypeList event_types;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
} else if (ceph_argparse_witharg(args, i, &val, "-i", "--uid", (char*)NULL)) {
user_id.from_str(val);
+ if (user_id.empty()) {
+ cerr << "no value for uid" << std::endl;
+ exit(1);
+ }
} else if (ceph_argparse_witharg(args, i, &val, "--tenant", (char*)NULL)) {
tenant = val;
} else if (ceph_argparse_witharg(args, i, &val, "--access-key", (char*)NULL)) {
} else if (ceph_argparse_witharg(args, i, &val, "--event-id", (char*)NULL)) {
event_id = val;
} else if (ceph_argparse_witharg(args, i, &val, "--event-type", "--event-types", (char*)NULL)) {
- get_str_set(val, ",", event_types);
+ rgw::notify::from_string_list(val, event_types);
} else if (ceph_argparse_binary_flag(args, i, &detail, NULL, "--detail", (char*)NULL)) {
// do nothing
} else if (strncmp(*i, "-", 1) == 0) {
// RGWUser to use for user operations
RGWUser user;
int ret = 0;
- if (!user_id.empty() || !subuser.empty()) {
+ if (!(user_id.empty() && access_key.empty()) || !subuser.empty()) {
ret = user.init(store, user_op);
if (ret < 0) {
cerr << "user.init failed: " << cpp_strerror(-ret) << std::endl;
switch (opt_cmd) {
case OPT_USER_INFO:
- if (user_id.empty()) {
- cerr << "ERROR: uid not specified" << std::endl;
+ if (user_id.empty() && access_key.empty()) {
+ cerr << "ERROR: --uid or --access-key required" << std::endl;
return EINVAL;
}
break;
if (opt_cmd == OPT_BUCKETS_LIST) {
if (bucket_name.empty()) {
+ if (!user_id.empty()) {
+ if (!user_op.has_existing_user()) {
+ cerr << "ERROR: could not find user: " << user_id << std::endl;
+ return -ENOENT;
+ }
+ }
RGWBucketAdminOp::info(store, bucket_op, f);
} else {
RGWBucketInfo bucket_info;
string user_str = user_id.to_str();
if (reset_stats) {
- if (!bucket_name.empty()){
- cerr << "ERROR: recalculate doesn't work on buckets" << std::endl;
+ if (!bucket_name.empty()) {
+ cerr << "ERROR: --reset-stats does not work on buckets and "
+ "bucket specified" << std::endl;
+ return EINVAL;
+ }
+ if (sync_stats) {
+ cerr << "ERROR: sync-stats includes the reset-stats functionality, "
+ "so at most one of the two should be specified" << std::endl;
return EINVAL;
}
ret = store->cls_user_reset_stats(user_str);
if (ret < 0) {
- cerr << "ERROR: could not clear user stats: " << cpp_strerror(-ret) << std::endl;
+ cerr << "ERROR: could not reset user stats: " << cpp_strerror(-ret) <<
+ std::endl;
return -ret;
}
}
if (!bucket_name.empty()) {
int ret = rgw_bucket_sync_user_stats(store, tenant, bucket_name);
if (ret < 0) {
- cerr << "ERROR: could not sync bucket stats: " << cpp_strerror(-ret) << std::endl;
+ cerr << "ERROR: could not sync bucket stats: " <<
+ cpp_strerror(-ret) << std::endl;
return -ret;
}
} else {
int ret = rgw_user_sync_all_stats(store, user_id);
if (ret < 0) {
- cerr << "ERROR: failed to sync user stats: " << cpp_strerror(-ret) << std::endl;
+ cerr << "ERROR: could not sync user stats: " <<
+ cpp_strerror(-ret) << std::endl;
return -ret;
}
}
}
RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id);
- ret = meta_log->trim(shard_id, start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker);
- if (ret < 0) {
+ // trim until -ENODATA
+ do {
+ ret = meta_log->trim(shard_id, start_time.to_real_time(),
+ end_time.to_real_time(), start_marker, end_marker);
+ } while (ret == 0);
+ if (ret < 0 && ret != -ENODATA) {
cerr << "ERROR: meta_log->trim(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (ret < 0)
return -ret;
- RGWDataChangesLog *log = store->data_log;
- ret = log->trim_entries(start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker);
- if (ret < 0) {
+ if (!specified_shard_id) {
+ cerr << "ERROR: requires a --shard-id" << std::endl;
+ return EINVAL;
+ }
+
+ // loop until -ENODATA
+ do {
+ auto datalog = store->data_log;
+ ret = datalog->trim_entries(shard_id, start_time.to_real_time(),
+ end_time.to_real_time(),
+ start_marker, end_marker);
+ } while (ret == 0);
+
+ if (ret < 0 && ret != -ENODATA) {
cerr << "ERROR: trim_entries(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWUserInfo& user_info = user_op.get_user_info();
RGWUserPubSub ups(store, user_info.user_id);
- RGWUserPubSub::Sub::list_events_result result;
-
if (!max_entries_specified) {
- max_entries = 100;
+ max_entries = RGWUserPubSub::Sub::DEFAULT_MAX_EVENTS;
}
auto sub = ups.get_sub(sub_name);
- ret = sub->list_events(marker, max_entries, &result);
+ ret = sub->list_events(marker, max_entries);
if (ret < 0) {
cerr << "ERROR: could not list events: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- encode_json("result", result, formatter);
+ encode_json("result", *sub, formatter);
formatter->flush(cout);
}