Commit 87f081c9 authored by Mike Ritter's avatar Mike Ritter Committed by Alexander Kukushkin
Browse files

Update retry policy in the callback_role.py (#291)

The new strategy is - never give up until the job is done. Patroni will cancel the callback script when it would be necessary.
Showing with 1 addition and 4 deletions
+1 -4
......@@ -18,7 +18,6 @@ KUBE_API_URL = 'https://kubernetes.default.svc.cluster.local/api/v1/namespaces'
logger = logging.getLogger(__name__)
NUM_ATTEMPTS = 10
LABEL = os.environ.get("KUBERNETES_ROLE_LABEL", 'spilo-role')
......@@ -36,7 +35,7 @@ def read_token():
def api_patch(namespace, kind, name, entity_name, body):
api_url = '/'.join([KUBE_API_URL, namespace, kind, name])
for i in range(NUM_ATTEMPTS):
while True:
try:
token = read_token()
if token:
......@@ -52,8 +51,6 @@ def api_patch(namespace, kind, name, entity_name, body):
except requests.exceptions.RequestException as e:
logger.warning('Exception when executing PATCH on %s: %s', api_url, e)
time.sleep(1)
else:
logger.error('Unable to change %s after %s attempts', entity_name, NUM_ATTEMPTS)
def change_pod_role_label(namespace, new_role):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment