Skip to content

Commit

Permalink
show errors received on registration (#86)
Browse files Browse the repository at this point in the history
Currently I'm trying to setup a storage controller in a new environment but registration is failing
with `Unable to find pageserver version from` message, which doesn't tell much. I'm sure there's a
configuration error somewhere but it's hard to debug when the message doesn't contain any details.

This PR changes the `get_data` method to raise an exception on unexpected responses so that the
status code and response body are shown. Also changes the same method to not silently discard
`urllib.error.URLError` if it happens.

This doesn't change the behavior of the registration script significantly because we're already
exiting if the response doesn't contain what we need.
  • Loading branch information
fcdm committed Jul 1, 2024
1 parent f217e4c commit 4e68735
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/neon-storage-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: neon-storage-controller
description: Neon storage controller
type: application
version: 1.0.11
version: 1.0.12
appVersion: "0.1.0"
kubeVersion: "^1.18.x-x"
home: https://neon.tech
Expand Down
2 changes: 1 addition & 1 deletion charts/neon-storage-controller/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# neon-storage-controller

![Version: 1.0.11](https://img.shields.io/badge/Version-1.0.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) [![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml)
![Version: 1.0.12](https://img.shields.io/badge/Version-1.0.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) [![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml)

Neon storage controller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ def get_data(url, token, host=None):
req = urllib.request.Request(url=url, headers=headers, method="GET")
try:
with urllib.request.urlopen(req) as response:
if response.getcode() == 200:
return json.loads(response.read())
except urllib.error.URLError:
pass
return {}
code = response.getcode()
response_body = response.read()
except urllib.error.HTTPError as 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):
Expand Down

0 comments on commit 4e68735

Please sign in to comment.