Deal with brokers that disappear, reappear with different IP address (#1085)
Deal with brokers that disappear, reappear with different IP address (#1085)

When KafkaClient connects to a broker in _maybe_connect,
it inserts into self._conns a BrokerConnection configured
with the current host/port for that node.  The BrokerConnection
remains there forever, though, so if the broker's IP or host
ever changes, KafkaClient has no way to deal with this.

The fix is to compare the latest metadata with the current
node's connection, and if the host/IP has changed, decommission
the old connection and allow a new one to be created.

There's also a common race condition on broker startup where
the initial metadata request sometimes returns an empty list
of brokers, but subsequent requests behave normally.  So, we
must deal with broker being None here.  This change is conservative
in that it doesn't remove the connection from self._conns unless
the new broker metadata contains an entry for that same node
with a new IP/port.

ohmu/kafka-python,mumrah/kafka-python,mumrah/kafka-python,dpkp/kafka-python,scrapinghub/kafka-python,Aloomaio/kafka-python,Aloomaio/kafka-python,scrapinghub/kafka-python,DataDog/kafka-python,ohmu/kafka-python,wikimedia/operations-debs-python-kafka,wikimedia/operations-debs-python-kafka,dpkp/kafka-python,Yelp/kafka-python,Yelp/kafka-python