Skip to content

Commit 9f223bd

Browse files
committed
chore(helmbroker): add debug config
1 parent 692aab2 commit 9f223bd

5 files changed

Lines changed: 23 additions & 6 deletions

File tree

rootfs/helmbroker/broker.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def provision(self,
4343
details: ProvisionDetails,
4444
async_allowed: bool,
4545
**kwargs) -> ProvisionedServiceSpec:
46+
logger.debug(f"*** provision instance {instance_id}")
4647
instance_path = get_instance_path(instance_id)
4748
if os.path.exists(instance_path):
4849
raise ErrInstanceAlreadyExists()
@@ -83,6 +84,7 @@ def bind(self,
8384
async_allowed: bool,
8485
**kwargs
8586
) -> Binding:
87+
logger.debug(f"*** bind instance {instance_id}")
8688
is_addon_bindable = get_addon_bindable(details.service_id)
8789
if not is_addon_bindable:
8890
raise ErrBadRequest(
@@ -110,7 +112,7 @@ def unbind(self,
110112
async_allowed: bool,
111113
**kwargs
112114
) -> UnbindSpec:
113-
logger.debug(f"unbind instance {instance_id}")
115+
logger.debug(f"*** unbind instance {instance_id}")
114116
unbind.delay(instance_id)
115117
return UnbindSpec(is_async=True)
116118

@@ -120,6 +122,7 @@ def update(self,
120122
async_allowed: bool,
121123
**kwargs
122124
) -> UpdateServiceSpec:
125+
logger.debug(f"*** update instance {instance_id}")
123126
instance_path = get_instance_path(instance_id)
124127
if not os.path.exists(instance_path):
125128
raise ErrBadRequest(msg="Instance %s does not exist" % instance_id)
@@ -156,6 +159,7 @@ def deprovision(self,
156159
details: DeprovisionDetails,
157160
async_allowed: bool,
158161
**kwargs) -> DeprovisionServiceSpec:
162+
logger.debug(f"*** deprovision instance {instance_id}")
159163
if not os.path.exists(get_instance_path(instance_id)):
160164
raise ErrInstanceDoesNotExist()
161165
with new_instance_lock(instance_id):
@@ -175,6 +179,7 @@ def last_operation(self,
175179
operation_data: Optional[str],
176180
**kwargs
177181
) -> LastOperation:
182+
logger.debug(f"*** last_operation instance {instance_id}")
178183
if os.path.exists(get_instance_file(instance_id)):
179184
data = load_instance_meta(instance_id)
180185
return LastOperation(
@@ -189,6 +194,7 @@ def last_binding_operation(self,
189194
operation_data: Optional[str],
190195
**kwargs
191196
) -> LastOperation:
197+
logger.debug(f"*** last_binding_operation instance {instance_id}")
192198
if os.path.exists(get_binding_file(instance_id)):
193199
data = load_binding_meta(instance_id)
194200
return LastOperation(

rootfs/helmbroker/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515

1616
class Config:
17-
DEBUG = bool(os.environ.get('HELMBROKER_DEBUG', True))
17+
DEBUG = bool(os.environ.get('HELMBROKER_DEBUG', False))

rootfs/helmbroker/gunicorn/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import os
21
from gunicorn.glogging import Logger
2+
from helmbroker.config import Config
33

44

55
class Logging(Logger):
66
def access(self, resp, req, environ, request_time):
77
# health check endpoints are only logged in debug mode
88
if (
9-
not os.environ.get('DEBUG', False) and
9+
not Config.DEBUG and
1010
req.path in ['/readiness', '/healthz']
1111
):
1212
return

rootfs/helmbroker/tasks.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020

2121
@app.task(serializer='pickle')
2222
def provision(instance_id: str, details: ProvisionDetails):
23+
logger.debug(f"*** task provision instance: {instance_id}, before lock")
2324
with (
2425
new_instance_lock(instance_id),
2526
run_instance_hooks(instance_id, "provision") as (status, output)
2627
):
28+
logger.debug(f"*** task provision instance: {instance_id}")
2729
backup_instance(instance_id)
2830
# create instance.json
2931
data = {
@@ -78,10 +80,12 @@ def provision(instance_id: str, details: ProvisionDetails):
7880

7981
@app.task(serializer='pickle')
8082
def update(instance_id: str, details: UpdateDetails):
83+
logger.debug(f"*** task update instance: {instance_id}, before lock")
8184
with (
8285
new_instance_lock(instance_id),
8386
run_instance_hooks(instance_id, "update") as (status, output)
8487
):
88+
logger.debug(f"*** task update instance: {instance_id}")
8589
backup_instance(instance_id)
8690
data = load_instance_meta(instance_id)
8791
if details.service_id:
@@ -133,10 +137,12 @@ def bind(instance_id: str,
133137
details: BindDetails,
134138
async_allowed: bool,
135139
**kwargs):
140+
logger.debug(f"*** task bind instance: {instance_id}, before lock")
136141
with (
137142
new_instance_lock(instance_id),
138143
run_instance_hooks(instance_id, "bind") as (status, output)
139144
):
145+
logger.debug(f"*** task bind instance: {instance_id}")
140146
backup_instance(instance_id)
141147
data = {"binding_id": binding_id, "credentials": {}, "last_operation": {}}
142148
if status != 0:
@@ -199,10 +205,12 @@ def bind(instance_id: str,
199205

200206
@app.task(serializer='pickle')
201207
def unbind(instance_id):
208+
logger.debug(f"*** task unbind instance: {instance_id}, before lock")
202209
with (
203210
new_instance_lock(instance_id),
204-
run_instance_hooks(instance_id, "deprovision") as (status, output)
211+
run_instance_hooks(instance_id, "unbind") as (status, output)
205212
):
213+
logger.debug(f"*** task unbind instance: {instance_id}")
206214
backup_instance(instance_id)
207215
data = load_binding_meta(instance_id)
208216
if status != 0:
@@ -220,10 +228,12 @@ def unbind(instance_id):
220228

221229
@app.task(serializer='pickle')
222230
def deprovision(instance_id: str):
231+
logger.debug(f"*** task deprovision instance: {instance_id}, before lock")
223232
with (
224233
new_instance_lock(instance_id),
225234
run_instance_hooks(instance_id, "deprovision") as (status, output)
226235
):
236+
logger.debug(f"*** task deprovision instance: {instance_id}")
227237
backup_instance(instance_id)
228238
data = load_instance_meta(instance_id)
229239
if status != 0:

rootfs/helmbroker/wsgi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import logging
23
from flask import Flask, make_response
34
from openbrokerapi import api, log_util
45
from helmbroker.broker import HelmServiceBroker
@@ -27,5 +28,5 @@ def readiness():
2728
catalog_api = api.get_blueprint(
2829
HelmServiceBroker(),
2930
api.BrokerCredentials(USERNAME, PASSWORD),
30-
log_util.basic_config())
31+
log_util.basic_config(level=logging.DEBUG if Config.DEBUG else logging.INFO))
3132
application.register_blueprint(catalog_api)

0 commit comments

Comments
 (0)