From 797b1588a0770e9e2e153642026bc89b7f0c9991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GP=20=E2=9C=85?= Date: Fri, 3 Aug 2018 18:38:13 +0530 Subject: [PATCH] Follow redirects from non-leaders in Marathon 1.7 (#595) Marathon 1.7.x returns a 302 redirect response from a non-leader. So we make sure Marathon-lb can follow it to the leader. Related Marathon JIRA card: https://jira.mesosphere.com/projects/MARATHON/issues/MARATHON-7178 Fixes #594 --- utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils.py b/utils.py index 502bba8c..0d0301e2 100644 --- a/utils.py +++ b/utils.py @@ -158,6 +158,11 @@ def __init__(self, url, auth, verify): self.curl.setopt(pycurl.CONNECTTIMEOUT, 10) self.curl.setopt(pycurl.WRITEDATA, self.received_buffer) + # Marathon >= 1.7.x returns 30x responses for /v2/events responses + # when they're coming from a non-leader. So we follow redirects. + self.curl.setopt(pycurl.FOLLOWLOCATION, True) + self.curl.setopt(pycurl.MAXREDIRS, 1) + # The below settings are to prevent the connection from hanging if the # connection breaks silently. Since marathon-lb only listens, silent # connection failure results in marathon-lb waiting infinitely.