Skip to content
Snippets Groups Projects
Commit 2ecbe81a authored by Arie Peterson's avatar Arie Peterson
Browse files

Reload on change to app/oauthclient configmaps

parent 92282da8
No related branches found
Tags 0.10.2
1 merge request!180Resolve "Creating initial admin user fails due to missing apps"
Pipeline #45816 passed with stages
in 4 minutes and 14 seconds
......@@ -55,7 +55,7 @@ def create_app(slug, name, external_url = None):
:param extenal-url: if set, it marks this as an external app and
configures the url
"""
current_app.logger.info(f"Creating app definition: {name} ({slug}")
current_app.logger.info(f"Creating app definition: {name} ({slug})")
obj = App(name=name, slug=slug)
......
......@@ -436,17 +436,17 @@ def debounce(timeout: float):
return decorator
def watch_dashboard_config(app, reload):
# Number of seconds to wait before reloading in case more secrets show up.
# In particular this prevents us from reloading once for every
# secret that exists at startup in succession.
debounce_timeout = 1
@debounce(debounce_timeout)
def debounced_reload():
reload()
w = watch.Watch()
api_instance = client.CoreV1Api(api_client.ApiClient())
def p():
def watch_scim_secrets():
with app.app_context():
# Number of seconds to wait before reloading in case more secrets show up.
# In particular this prevents us from reloading once for every
# secret that exists at startup in succession.
debounce_timeout = 1
@debounce(debounce_timeout)
def debounced_reload():
reload()
for event in w.stream(
api_instance.list_namespaced_secret,
'flux-system',
......@@ -455,8 +455,18 @@ def watch_dashboard_config(app, reload):
):
current_app.logger.info(f"{event['type']} SCIM config secret: {event['object'].metadata.name}")
debounced_reload()
thread = threading.Thread(target=p)
thread.start()
threading.Thread(target=watch_scim_secrets).start()
def watch_dashboard_configmaps():
with app.app_context():
for event in w.stream(
api_instance.list_namespaced_config_map,
'flux-system',
label_selector="stackspin.net/dashboard-config=1",
watch=True
):
current_app.logger.info(f"{event['type']} dashboard config configmap: {event['object'].metadata.name}")
debounced_reload()
threading.Thread(target=watch_dashboard_configmaps).start()
def check_condition(status):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment