t.put(MONITOR_NAME, COMPAT_SET_LOC, bl);
}
+int Monitor::sanitize_options()
+{
+ int r = 0;
+
+ // mon_lease must be greater than mon_lease_renewal; otherwise we
+ // may incur in leases expiring before they are renewed.
+ if (g_conf->mon_lease <= g_conf->mon_lease_renew_interval) {
+ derr << "'mon_lease' (val: " << g_conf->mon_lease << ") must be greater "
+ << "than 'mon_lease_renew_interval' (val: "
+ << g_conf->mon_lease_renew_interval << ")" << dendl;
+ r = -EINVAL;
+ }
+
+ // mon_lease_ack_timeout must be greater than mon_lease to make sure we've
+ // got time to renew the lease and get an ack for it. Having both options
+ // with the same value, for a given small vale, could mean timing out if
+ // the monitors happened to be overloaded -- or even under normal load for
+ // a small enough value.
+ if (g_conf->mon_lease_ack_timeout <= g_conf->mon_lease) {
+ derr << "'mon_lease_ack_timeout' (val: " << g_conf->mon_lease_ack_timeout
+ << ") must be greater than 'mon_lease' (val: "
+ << g_conf->mon_lease << ")" << dendl;
+ r = -EINVAL;
+ }
+ return r;
+}
+
int Monitor::preinit()
{
lock.Lock();
dout(1) << "preinit fsid " << monmap->fsid << dendl;
-
+
+ int r = sanitize_options();
+ if (r < 0) {
+ derr << "option sanitization failed!" << dendl;
+ return r;
+ }
+
assert(!logger);
{
PerfCountersBuilder pcb(g_ceph_context, "mon", l_mon_first, l_mon_last);
init_paxos();
health_monitor->init();
- int r;
-
if (is_keyring_required()) {
// we need to bootstrap authentication keys so we can form an
// initial quorum.