From da379c95e4e3fe4dbe4d810a27a2d0b821cb2fb1 Mon Sep 17 00:00:00 2001 From: Ewen Cheslack-Postava Date: Wed, 21 Feb 2018 10:52:27 -0800 Subject: [PATCH] MINOR: Cancel port forwarding for HttpMetricsCollector during cleanup Currently port forwarding is setup for HttpMetricsCollector when the Service's start_node method is called, but not canceled during stop. This hasn't presented a problem so far because we don't have tests that use this *and* restart the service. However, if a test/service does that, it will throw an exception since the port is already bound. This just does the cleanup when stopping so a subsequent attempt to start again will succeed. https://jenkins.confluent.io/job/system-test-kafka-branch-builder/1320 is a test run for a Test that uses ProducerPerformanceService, which in turn uses HttpMetricsCollector to validate the change. Author: Ewen Cheslack-Postava Reviewers: Ismael Juma , Apurva Mehta Closes #4604 from ewencp/cleanup-reverse-port-forward --- tests/kafkatest/services/monitor/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/kafkatest/services/monitor/http.py b/tests/kafkatest/services/monitor/http.py index 83324dfd4a1..88ddb2ef68f 100644 --- a/tests/kafkatest/services/monitor/http.py +++ b/tests/kafkatest/services/monitor/http.py @@ -173,6 +173,7 @@ class _ReverseForwarder(object): self.logger = logger self._node = node self._local_port = local_port + self._remote_port = remote_port self.logger.debug('Forwarding %s port %d to driver port %d', node, remote_port, local_port) @@ -189,6 +190,7 @@ class _ReverseForwarder(object): self._accept_thread.join(30) if self._accept_thread.isAlive(): raise RuntimeError("Failed to stop reverse forwarder on %s", self._node) + self._transport.cancel_port_forward('', self._remote_port) def _accept(self): while not self._stopping: