|
25 | 25 | from flask_oauthlib.client import OAuth
|
26 | 26 | from functools import wraps
|
27 | 27 | from gevent import sleep, spawn
|
28 |
| -from gevent.wsgi import WSGIServer |
| 28 | +from gevent.pywsgi import WSGIServer |
29 | 29 | from jq import jq
|
30 | 30 | from json import dumps, loads
|
31 | 31 | from logging import DEBUG, ERROR, INFO, basicConfig, exception, getLogger
|
|
44 | 44 | create_postgresql,
|
45 | 45 | read_basebackups,
|
46 | 46 | read_namespaces,
|
| 47 | + read_pooler, |
47 | 48 | read_pods,
|
48 | 49 | read_postgresql,
|
49 | 50 | read_postgresqls,
|
|
80 | 81 | OPERATOR_UI_CONFIG = getenv('OPERATOR_UI_CONFIG', '{}')
|
81 | 82 | OPERATOR_UI_MAINTENANCE_CHECK = getenv('OPERATOR_UI_MAINTENANCE_CHECK', '{}')
|
82 | 83 | READ_ONLY_MODE = getenv('READ_ONLY_MODE', False) in [True, 'true']
|
| 84 | +RESOURCES_VISIBLE = getenv('RESOURCES_VISIBLE', True) |
83 | 85 | SPILO_S3_BACKUP_PREFIX = getenv('SPILO_S3_BACKUP_PREFIX', 'spilo/')
|
84 | 86 | SUPERUSER_TEAM = getenv('SUPERUSER_TEAM', 'acid')
|
85 | 87 | TARGET_NAMESPACE = getenv('TARGET_NAMESPACE')
|
@@ -312,6 +314,7 @@ def index():
|
312 | 314 | def get_config():
|
313 | 315 | config = loads(OPERATOR_UI_CONFIG) or DEFAULT_UI_CONFIG
|
314 | 316 | config['read_only_mode'] = READ_ONLY_MODE
|
| 317 | + config['resources_visible'] = RESOURCES_VISIBLE |
315 | 318 | config['superuser_team'] = SUPERUSER_TEAM
|
316 | 319 | config['target_namespace'] = TARGET_NAMESPACE
|
317 | 320 |
|
@@ -397,6 +400,22 @@ def get_service(namespace: str, cluster: str):
|
397 | 400 | )
|
398 | 401 |
|
399 | 402 |
|
| 403 | +@app.route('/pooler/<namespace>/<cluster>') |
| 404 | +@authorize |
| 405 | +def get_list_poolers(namespace: str, cluster: str): |
| 406 | + |
| 407 | + if TARGET_NAMESPACE not in ['', '*', namespace]: |
| 408 | + return wrong_namespace() |
| 409 | + |
| 410 | + return respond( |
| 411 | + read_pooler( |
| 412 | + get_cluster(), |
| 413 | + namespace, |
| 414 | + "{}-pooler".format(cluster), |
| 415 | + ), |
| 416 | + ) |
| 417 | + |
| 418 | + |
400 | 419 | @app.route('/statefulsets/<namespace>/<cluster>')
|
401 | 420 | @authorize
|
402 | 421 | def get_list_clusters(namespace: str, cluster: str):
|
@@ -587,6 +606,17 @@ def update_postgresql(namespace: str, cluster: str):
|
587 | 606 |
|
588 | 607 | spec['volume'] = {'size': size}
|
589 | 608 |
|
| 609 | + if 'enableConnectionPooler' in postgresql['spec']: |
| 610 | + cp = postgresql['spec']['enableConnectionPooler'] |
| 611 | + if not cp: |
| 612 | + if 'enableConnectionPooler' in o['spec']: |
| 613 | + del o['spec']['enableConnectionPooler'] |
| 614 | + else: |
| 615 | + spec['enableConnectionPooler'] = True |
| 616 | + else: |
| 617 | + if 'enableConnectionPooler' in o['spec']: |
| 618 | + del o['spec']['enableConnectionPooler'] |
| 619 | + |
590 | 620 | if 'enableReplicaLoadBalancer' in postgresql['spec']:
|
591 | 621 | rlb = postgresql['spec']['enableReplicaLoadBalancer']
|
592 | 622 | if not rlb:
|
@@ -1006,7 +1036,7 @@ def init_cluster():
|
1006 | 1036 | def main(port, secret_key, debug, clusters: list):
|
1007 | 1037 | global TARGET_NAMESPACE
|
1008 | 1038 |
|
1009 |
| - basicConfig(level=DEBUG if debug else INFO) |
| 1039 | + basicConfig(stream=sys.stdout, level=(DEBUG if debug else INFO), format='%(asctime)s %(levelname)s: %(message)s',) |
1010 | 1040 |
|
1011 | 1041 | init_cluster()
|
1012 | 1042 |
|
|
0 commit comments