Skip to content

Commit

Permalink
fix: storage controller registration script (#69)
Browse files Browse the repository at this point in the history
* fix: storage controller registration script

* fix python lint

* auto-gen chart docs and update version
  • Loading branch information
rahulinux authored Mar 4, 2024
1 parent 3fbbb09 commit 2e483a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 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.2
version: 1.0.3
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.2](https://img.shields.io/badge/Version-1.0.2-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.3](https://img.shields.io/badge/Version-1.0.3-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 @@ -65,7 +65,7 @@ def get_data(url, token, host=None):
def get_pageserver_id(url, token):
data = get_data(url, token, HOST)
if "node_id" in data:
return data["node_id"]
return int(data["node_id"])


def get_pageserver_version():
Expand Down Expand Up @@ -97,7 +97,7 @@ def register(url, token, payload):
response = json.loads(resp.read())
log.info(response)
if "node_id" in response:
return response["node_id"]
return int(response["node_id"])


if __name__ == "__main__":
Expand Down Expand Up @@ -132,7 +132,9 @@ def register(url, token, payload):
PAYLOAD.update(dict(version=version))

log.info("check if pageserver already registered or not in console")
node_id_in_console = get_pageserver_id(GLOBAL_CPLANE_URL, GLOBAL_CPLANE_JWT_TOKEN)
node_id_in_console = get_pageserver_id(
GLOBAL_CPLANE_URL, GLOBAL_CPLANE_JWT_TOKEN
)

if node_id_in_console is None:
log.info("Registering storage controller in console")
Expand All @@ -150,12 +152,16 @@ def register(url, token, payload):
)

log.info("check if pageserver already registered or not in cplane")
node_id_in_cplane = get_pageserver_id(LOCAL_CPLANE_URL, LOCAL_CPLANE_JWT_TOKEN)
node_id_in_cplane = get_pageserver_id(
LOCAL_CPLANE_URL, LOCAL_CPLANE_JWT_TOKEN
)

if node_id_in_cplane is None:
PAYLOAD.update(dict(node_id=str(node_id_in_console)))
if node_id_in_cplane is None and node_id_in_console is not None:
PAYLOAD.update(dict(node_id=node_id_in_console))
log.info("Registering storage controller in cplane")
node_id_in_cplane = register(LOCAL_CPLANE_URL, LOCAL_CPLANE_JWT_TOKEN, PAYLOAD)
node_id_in_cplane = register(
LOCAL_CPLANE_URL, LOCAL_CPLANE_JWT_TOKEN, PAYLOAD
)
log.info(
f"Storage controller registered in cplane with node_id \
{node_id_in_cplane}"
Expand Down

0 comments on commit 2e483a3

Please sign in to comment.