From 9e1f87de1f983696b80b2ea84c6f5b241fc6627d Mon Sep 17 00:00:00 2001 From: Cihan Demirci <128653800+fcdm@users.noreply.github.com> Date: Mon, 1 Jul 2024 19:05:30 +0100 Subject: [PATCH] consolidate code and response body --- .../scripts/register-storage-controller.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/charts/neon-storage-controller/scripts/register-storage-controller.py b/charts/neon-storage-controller/scripts/register-storage-controller.py index ff01509..a95f520 100644 --- a/charts/neon-storage-controller/scripts/register-storage-controller.py +++ b/charts/neon-storage-controller/scripts/register-storage-controller.py @@ -57,12 +57,14 @@ def get_data(url, token, host=None): with urllib.request.urlopen(req) as response: code = response.getcode() response_body = response.read() - if code == 200: - return json.loads(response_body) - - raise Exception(f'GET {url} returned unexpected response: {code} {response_body}') except urllib.error.HTTPError as e: - raise Exception(f'GET {e.url} returned unexpected response: {e.code}') from e + code = e.code + response_body = e.read() + + if code == 200: + return json.loads(response_body) + + raise Exception(f'GET {url} returned unexpected response: {code} {response_body}') def get_pageserver_id(url, token):