rgw: RGWPeriod::reflect() sets master zonegroup as default

if RGWPeriod::reflect() is called right after a 'realm pull', it will
create the zonegroup objects but not set any as default.  so the next
time RGWRados is initialized, create_defaults() will add a new 'default'
zonegroup and set it as the master.  this causes a 'period update' to
find multiple master zonegroups and fail with EINVAL

reflect() now calls set_as_default(exclusive=true) on the master
zonegroup to guarantee that a default is set

Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2016-04-12 16:21:13 -04:00
parent 18a5fddb90
commit 5230967dad

View File

@ -1204,6 +1204,14 @@ int RGWPeriod::reflect()
ldout(cct, 0) << "ERROR: failed to store zonegroup info for zonegroup=" << iter.first << ": " << cpp_strerror(-r) << dendl;
return r;
}
if (zg.is_master_zonegroup()) {
// set master as default if no default exists
r = zg.set_as_default(true);
if (r == 0) {
ldout(cct, 1) << "Set the period's master zonegroup " << zg.get_id()
<< " as the default" << dendl;
}
}
}
return 0;
}