cloudant/fabric — pull request #155 by mikewallace1979 (2014-09-09 20:59:33+00:00)
Title: Teach fabric_util:get_db/2 about maintenance mode

I'm pretty wary about this commit for two reasons:

1. It changes code which is executed for pretty much every request.
2. It involves security.
3. I'm not quite sure I'm rexi-ing properly.

Nevertheless it is a first pass at fixing BugzID: 34360 and it works. I have tested it using the process written up in the FB ticket and confirmed that the security object is now returned when previously it wasn't.

Commit message follows...
---

If the node servicing a request does not have a shard for the db
involved then fabric_util:get_db/2 can return a shard from a node
which is in maintenance mode. If that node is a replacement node
that has not yet been brought into the cluster then the security
object will be empty.

Because fabric:get_security/2 calls fabric_util:get_db/2 and is in
the code path for authorizing requests at the HTTP layer, this can
result in live nodes returning 403s.

This commit replaces an rpc:call/4 with a rexi:cast/4 and adds
a new rpc endpoint in fabric_rpc for opening single shards. This
uses set_io_priority which will reply with a rexi_EXIT if
maintenance mode is set.

BugzID: 34360