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

kraken: rgw: Realm set does not create a new period #14509

Merged
merged 3 commits into from Jul 7, 2017
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
37 changes: 26 additions & 11 deletions src/rgw/rgw_admin.cc
Expand Up @@ -3045,7 +3045,7 @@ int main(int argc, char **argv)
cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
formatter->open_object_section("realmss_list");
formatter->open_object_section("realms_list");
encode_json("default_info", default_id, formatter);
encode_json("realms", realms, formatter);
formatter->close_section();
Expand Down Expand Up @@ -3103,24 +3103,39 @@ int main(int argc, char **argv)
cerr << "no realm name or id provided" << std::endl;
return EINVAL;
}
if (infile.empty()) {
cerr << "no realm input file provided" << std::endl;
return EINVAL;
}
RGWRealm realm(realm_id, realm_name);
int ret = realm.init(g_ceph_context, store, false);
if (ret < 0) {
bool new_realm = false;
int ret = realm.init(g_ceph_context, store);
if (ret < 0 && ret != -ENOENT) {
cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
return -ret;
} else if (ret == -ENOENT) {
new_realm = true;
}
ret = read_decode_json(infile, realm);
if (ret < 0) {
return 1;
}
ret = realm.update();
if (ret < 0) {
cerr << "ERROR: couldn't store realm info: " << cpp_strerror(-ret) << std::endl;
return 1;
if (!realm_name.empty() && realm.get_name() != realm_name) {
cerr << "mismatch between --rgw-realm " << realm_name << " and json input file name " <<
realm.get_name() << std::endl;
return EINVAL;
}
/* new realm */
if (new_realm) {
cout << "clearing period and epoch for new realm" << std::endl;
realm.clear_current_period_and_epoch();
ret = realm.create();
if (ret < 0) {
cerr << "ERROR: couldn't create new realm: " << cpp_strerror(-ret) << std::endl;
return 1;
}
} else {
ret = realm.update();
if (ret < 0) {
cerr << "ERROR: couldn't store realm info: " << cpp_strerror(-ret) << std::endl;
return 1;
}
}

if (set_default) {
Expand Down
5 changes: 4 additions & 1 deletion src/rgw/rgw_rados.h
Expand Up @@ -1503,7 +1503,10 @@ class RGWRealm : public RGWSystemMetaObj
return current_period;
}
int set_current_period(RGWPeriod& period);

void clear_current_period_and_epoch() {
current_period.clear();
epoch = 0;
}
epoch_t get_epoch() const { return epoch; }

string get_control_oid();
Expand Down