mon: Paxos: add propose_queued() and list_proposals() functions

This allows us to remove duplicate code from several parts of the code,
making it easier to maintain and read.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: change Proposal output format

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: keep time of proposal and output waiting time once proposed

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PGMonitor: Wait for readable and writable using PaxosService interface

We cannot wait on Paxos if we are waiting for PaxosService state changes.
For instance, the service may not be writable because it has a queued
proposal, but the Paxos may be (even though momentarily) on state ACTIVE.

We need to cope with this, and the way to do it is by using the PaxosService
wait_for_*() functions.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: clean obsolete asserts, and bring old ones back to life.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: bring old, commented-out asserts back to life

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: wait_for_readable() on PaxosService instead of Paxos...

... if the reason for waiting is related to the version we're seeking, or
due to the fact that we haven't committed a version yet.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: output the time the proposal took since it was queued until it finished

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: fixing assert condition on propose_queued()

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: wake-up waiters after going through _active()

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: remove proposal from queue before calling finish()

The finish() function on the proposal will call the PaxosService::_active,
which in turn may end up calling Paxos::propose_new_value. Since we assume
that, one we start proposing he head of the queue, it hasn't been proposed
yet, we must make sure the old proposal is no longer there.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: Check if we're still the leader before proposing on finish_proposal

We assumed that, if we reached finish_proposal(), then we had to be the
leader. Obviously, this didn't take into consideration someone coming up
and taking the leadership from under us...

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
auth: cephx: debug: print secrets when entity not found

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: debug queued proposals every time we wait on something

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: Clear the proposal state when an election is finished

The Paxos will clear everything in the proposal queue when an election
finishes, so our proposal (if queued) will be gone. If we were waiting on
it, we'll be in trouble. Therefore, clear our proposal state and move on.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: AuthMonitor: wait for finished proposal instead of commit

We have been waiting for Paxos to finish committing in order to send our
command ack messages. Although this does not pose a problem per se, since
it is assumed that it should *eventually* be true, there is a chance that
it might not. It happens that if we bootstrap before our proposal is
handled, our proposal will not be taken care of and acking our command is
and invalid behavior. Thus, we really must depend solely on the PaxosService
waiting queue for finer grained control.

Let me know if this isn't as clear as possible.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: clear proposal queue when we restart

We were clearing the proposal queue only when the election finished. If we
are to follow what Paxos did before, we also must clear it once the Paxos
restart.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: clear waiting_for_finished_proposal callback list on restart, shutdown and election_finished()

Follow Paxos on this one.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Paxos: hack around the possibility of bootstraps while we have pending proposals

The MonmapMonitor may issue bootstraps once it is updated. We must ensure
that we propose every single pending proposal before we actually do it.

note: this feature shall be used by the PaxosService and the MonmapMonitor
on patches to follow.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: PaxosService: consider if a bootstrap is about to happen when we check for our state.

We don't want to propose if we are going to bootstrap; otherwise, we may
end up losing proposals.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>