From 3dc1f57de21e8d23c609bc606b3c292178d3204c Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 5 Nov 2023 17:10:46 -0500 Subject: [PATCH] Revert "Switch to ZK+PG over Redis for Celery queue" This reverts commit 54215bab6c1c420bc284160c6c4633e0ab2e8ff2. --- api-daemon/pvcapid.sample.yaml | 12 ++++++++++-- api-daemon/pvcapid/Daemon.py | 3 +++ api-daemon/pvcapid/flaskapi.py | 22 ++++------------------ debian/control | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/api-daemon/pvcapid.sample.yaml b/api-daemon/pvcapid.sample.yaml index 4d280c78..e8fadf90 100644 --- a/api-daemon/pvcapid.sample.yaml +++ b/api-daemon/pvcapid.sample.yaml @@ -45,8 +45,8 @@ pvc: provisioner: # database: Backend database configuration database: - # host: PostgreSQL hostname, the primary coordinator floating IP in the cluster network - host: pvchvP + # host: PostgreSQL hostname, usually 'localhost' + host: localhost # port: PostgreSQL port, invariably '5432' port: 5432 # name: PostgreSQL database name, invariably 'pvcapi' @@ -55,6 +55,14 @@ pvc: user: pvcapi # pass: PostgreSQL user password, randomly generated pass: pvcapi + # queue: Celery backend queue using the PVC Zookeeper cluster + queue: + # host: Redis hostname, usually 'localhost' + host: localhost + # port: Redis port, invariably '6279' + port: 6379 + # path: Redis queue path, invariably '/0' + path: /0 # ceph_cluster: Information about the Ceph storage cluster ceph_cluster: # storage_hosts: The list of hosts that the Ceph monitors are valid on; if empty (the default), diff --git a/api-daemon/pvcapid/Daemon.py b/api-daemon/pvcapid/Daemon.py index 6e763465..2429d98a 100755 --- a/api-daemon/pvcapid/Daemon.py +++ b/api-daemon/pvcapid/Daemon.py @@ -90,6 +90,9 @@ try: "database_name": o_config["pvc"]["provisioner"]["database"]["name"], "database_user": o_config["pvc"]["provisioner"]["database"]["user"], "database_password": o_config["pvc"]["provisioner"]["database"]["pass"], + "queue_host": o_config["pvc"]["provisioner"]["queue"]["host"], + "queue_port": o_config["pvc"]["provisioner"]["queue"]["port"], + "queue_path": o_config["pvc"]["provisioner"]["queue"]["path"], "storage_hosts": o_config["pvc"]["provisioner"]["ceph_cluster"][ "storage_hosts" ], diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index 7de4e876..67fcf0cf 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -43,23 +43,11 @@ from flask_sqlalchemy import SQLAlchemy # Create Flask app and set config values app = flask.Flask(__name__) - -# Set up Celery queue -# Default Zookeeper port; not configurable -queue_port = 2181 -# Default Zookeeper path, not configurable -queue_path = "/apibroker" -# Join the coordinator hostnames with the queue port, semicolon separated for Celery -queue_hostport_pairs = ";".join([f"{h}:{queue_port}" for h in config["coordinators"]]) -app.config["CELERY_BROKER_URL"] = "zookeeper://{}{}".format( - queue_hostport_pairs, queue_path +app.config["CELERY_BROKER_URL"] = "redis://{}:{}{}".format( + config["queue_host"], config["queue_port"], config["queue_path"] ) -app.config["CELERY_RESULT_BACKEND"] = "db+postgresql://{}:{}@{}:{}/{}".format( - config["database_user"], - config["database_password"], - config["database_host"], - config["database_port"], - config["database_name"], +app.config["CELERY_RESULT_BACKEND"] = "redis://{}:{}{}".format( + config["queue_host"], config["queue_port"], config["queue_path"] ) # Set up Celery queues @@ -111,13 +99,11 @@ app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://{}:{}@{}:{}/{}".format( config["database_name"], ) -# Set up debugging if config["debug"]: app.config["DEBUG"] = True else: app.config["DEBUG"] = False -# Set up authentication if config["auth_enabled"]: app.config["SECRET_KEY"] = config["auth_secret_key"] diff --git a/debian/control b/debian/control index b5a26545..26edb9ac 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,7 @@ Description: Parallel Virtual Cluster node daemon (Python 3) Package: pvc-daemon-api Architecture: all -Depends: systemd, pvc-daemon-common, python3-yaml, python3-flask, python3-flask-restful, python3-celery, python-celery-common, python3-distutils, python3-lxml, python3-flask-migrate, fio +Depends: systemd, pvc-daemon-common, python3-yaml, python3-flask, python3-flask-restful, python3-celery, python-celery-common, python3-distutils, redis, python3-redis, python3-lxml, python3-flask-migrate, fio Description: Parallel Virtual Cluster API daemon (Python 3) A KVM/Zookeeper/Ceph-based VM and private cloud manager .