Fix concurrency of cleanup jobs
Anirudh Oppiliappan x@icyphox.sh
Sun, 14 Mar 2021 13:46:31 +0530
2 files changed,
4 insertions(+),
3 deletions(-)
M
deploy/deployment.yaml
→
deploy/deployment.yaml
@@ -23,6 +23,6 @@ image: janny:latest
imagePullPolicy: IfNotPresent args: - "--included-resources" - - "deployments,configmaps,pods" + - "deployments,services,ingresses" - "--namespaces" - "default"
M
janny/main.py
→
janny/main.py
@@ -47,12 +47,13 @@ """
url, resource = resource_tuple resource_list = get(f"{url}/namespaces/{namespace}/{resource.name}") try: + # items = [i for r in resource_list.items if "janny.ttl" in vars(r.metadata.annotations) and r.metadata.name not in RUNNING] for r in resource_list.items: try: annotations = vars(r.metadata.annotations) if ( "janny.ttl" in annotations - and r.metadata.name not in RUNNING + and f"{resource}/{r.metadata.name}" not in RUNNING ): logger.info( f"New resource to clean up: {resource.name}/{r.metadata.name}: ttl: {annotations['janny.ttl']}"@@ -69,7 +70,7 @@ namespace,
], ) logger.info(f"Starting cleaner thread for {r.metadata.name}") - RUNNING.append(r.metadata.name) + RUNNING.append(f"{resource}/{r.metadata.name}") t.start() except AttributeError: pass