From 0ed1ca0d1f9855273f648016cb5e181ce7f848b3 Mon Sep 17 00:00:00 2001 From: catattack05 <105679648+catattack05@users.noreply.github.com> Date: Mon, 15 Aug 2022 13:16:29 -0400 Subject: [PATCH] Remove brew-view and bartender references (#402) --- brewtils/request_handling.py | 40 +++++++++++++++++------------------ test/request_handling_test.py | 22 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/brewtils/request_handling.py b/brewtils/request_handling.py index d3d4c9dc..d19786b9 100644 --- a/brewtils/request_handling.py +++ b/brewtils/request_handling.py @@ -383,9 +383,9 @@ def __init__(self, ez_client, shutdown_event, **kwargs): self.max_timeout = kwargs.get("max_timeout", 30) self.starting_timeout = kwargs.get("starting_timeout", 5) - # Tightly manage when we're in an 'error' state, aka Brew-view is down - self.brew_view_error_condition = threading.Condition() - self.brew_view_down = False + # Tightly manage when we're in an 'error' state, aka beergarden is down + self.beergarden_error_condition = threading.Condition() + self.beergarden_down = False self.logger.debug("Creating and starting connection poll thread") self.connection_poll_thread = self._create_connection_poll_thread() @@ -393,15 +393,15 @@ def __init__(self, ez_client, shutdown_event, **kwargs): def shutdown(self): self.logger.debug("Shutting down, about to wake any sleeping updater threads") - with self.brew_view_error_condition: - self.brew_view_error_condition.notify_all() + with self.beergarden_error_condition: + self.beergarden_error_condition.notify_all() def update_request(self, request, headers): """Sends a Request update to beer-garden Ephemeral requests do not get updated, so we simply skip them. - If brew-view appears to be down, it will wait for brew-view to come back + If beergarden appears to be down, it will wait for beergarden to come back up before updating. If this is the final attempt to update, we will attempt a known, good @@ -422,9 +422,9 @@ def update_request(self, request, headers): sys.stdout.flush() return - with self.brew_view_error_condition: + with self.beergarden_error_condition: - self._wait_for_brew_view_if_down(request) + self._wait_for_beergarden_if_down(request) try: if not self._should_be_final_attempt(headers): @@ -460,10 +460,10 @@ def _wait_if_not_first_attempt(self, headers): def _handle_request_update_failure(self, request, headers, exc): - # If brew-view is down, we always want to try again + # If beergarden is down, we always want to try again # Yes, even if it is the 'final_attempt' if isinstance(exc, (RequestsConnectionError, RestConnectionError)): - self.brew_view_down = True + self.beergarden_down = True self.logger.error( "Error updating request status: {0} exception: {1}".format( request.id, exc @@ -528,14 +528,14 @@ def _should_be_final_attempt(self, headers): return self.max_attempts <= headers.get("retry_attempt", 0) - def _wait_for_brew_view_if_down(self, request): - if self.brew_view_down and not self._shutdown_event.is_set(): + def _wait_for_beergarden_if_down(self, request): + if self.beergarden_down and not self._shutdown_event.is_set(): self.logger.warning( - "Currently unable to communicate with Brew-view, about to wait " + "Currently unable to communicate with beergarden, about to wait " "until connection is reestablished to update request %s", request.id, ) - self.brew_view_error_condition.wait() + self.beergarden_error_condition.wait() def _create_connection_poll_thread(self): connection_poll_thread = threading.Thread(target=self._connection_poll) @@ -547,18 +547,18 @@ def _connection_poll(self): while not self._shutdown_event.wait(5): try: - with self.brew_view_error_condition: - if self.brew_view_down: + with self.beergarden_error_condition: + if self.beergarden_down: try: self._ez_client.get_version() except Exception: - self.logger.debug("Brew-view reconnection attempt failure") + self.logger.debug("Beergarden reconnection attempt failure") else: self.logger.info( - "Brew-view connection reestablished, about to " + "Beergarden connection reestablished, about to " "notify any waiting requests" ) - self.brew_view_down = False - self.brew_view_error_condition.notify_all() + self.beergarden_down = False + self.beergarden_error_condition.notify_all() except Exception as ex: self.logger.exception("Exception in connection poll thread: %s", ex) diff --git a/test/request_handling_test.py b/test/request_handling_test.py index bc93c016..14b9baef 100644 --- a/test/request_handling_test.py +++ b/test/request_handling_test.py @@ -409,12 +409,12 @@ def test_errors(self, updater, client, bg_request, ex, raised, bv_down): with pytest.raises(raised): updater.update_request(bg_request, {}) assert client.update_request.called is True - assert updater.brew_view_down is bv_down + assert updater.beergarden_down is bv_down def test_wait_during_error(self, updater, client, bg_request): error_condition_mock = MagicMock() - updater.brew_view_error_condition = error_condition_mock - updater.brew_view_down = True + updater.beergarden_error_condition = error_condition_mock + updater.beergarden_down = True updater.update_request(bg_request, {}) assert error_condition_mock.wait.called is True @@ -455,31 +455,31 @@ def test_shut_down(self, updater, client, shutdown_event): updater._connection_poll() assert client.get_version.called is False - def test_brew_view_normal(self, updater, client, shutdown_event): + def test_beergarden_normal(self, updater, client, shutdown_event): shutdown_event.wait.side_effect = [False, True] updater._connection_poll() assert client.get_version.called is False - def test_brew_view_down(self, updater, client, shutdown_event): + def test_beergarden_down(self, updater, client, shutdown_event): shutdown_event.wait.side_effect = [False, True] - updater.brew_view_down = True + updater.beergarden_down = True client.get_version.side_effect = ValueError updater._connection_poll() assert client.get_version.called is True - assert updater.brew_view_down is True + assert updater.beergarden_down is True - def test_brew_view_back(self, updater, client, shutdown_event): + def test_beergarden_back(self, updater, client, shutdown_event): shutdown_event.wait.side_effect = [False, True] - updater.brew_view_down = True + updater.beergarden_down = True updater._connection_poll() assert client.get_version.called is True - assert updater.brew_view_down is False + assert updater.beergarden_down is False def test_never_die(self, monkeypatch, updater, client, shutdown_event): - monkeypatch.setattr(updater, "brew_view_error_condition", None) + monkeypatch.setattr(updater, "beergarden_error_condition", None) shutdown_event.wait.side_effect = [False, True] # Test passes if this doesn't raise