From 9495a41f850936d90f5c8c3827e755985b29c6b8 Mon Sep 17 00:00:00 2001
From: Jarrod Johnson <jjohnson2@lenovo.com>
Date: Mon, 1 Oct 2018 15:29:18 -0400
Subject: [PATCH] Cancel retry if we become leader

If an instance is first to start, it's retry should be canceled
when other members prod it to become leader.
---
 confluent_server/confluent/collective/manager.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py
index 5f326591..bf851376 100644
--- a/confluent_server/confluent/collective/manager.py
+++ b/confluent_server/confluent/collective/manager.py
@@ -500,11 +500,15 @@ def retire_as_leader():
 def become_leader(connection):
     global currentleader
     global follower
+    global retrythread
     log.log({'info': 'Becoming leader of collective',
              'subsystem': 'collective'})
     if follower:
         follower.kill()
         follower = None
+    if retrythread:
+        retrythread.cancel()
+        retrythread = None
     currentleader = connection.getsockname()[0]
     skipaddr = connection.getpeername()[0]
     myname = get_myname()