changeset 70:68164135ae66

refactor tasks.py to smaller steps
author drewp@bigasterisk.com
date Fri, 03 May 2024 11:56:59 -0700
parents 6a021aa7b4be
children bfacf01fd119
files tasks.py
diffstat 1 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tasks.py	Fri May 03 11:56:34 2024 -0700
+++ b/tasks.py	Fri May 03 11:56:59 2024 -0700
@@ -15,19 +15,27 @@
 
 
 @task
+def build_k8s_config(ctx):
+    ctx.run('pdm run python create_k8s.py')
+
+
+@task
+def build_scrape_config(ctx):
+    ctx.run('pdm run python create_scrape_configs.py')
+
+
+@task(pre=[build_k8s_config, build_scrape_config])
 def push_config(ctx):
-    # plan:
-    #   every discovered service may:
-    #      - be described here as a forever retention - ignore the discovery
-    #      - be blocked here as a no-metrics service - ignore the discovery
-    #      - be scraped as 'recent', with possible overrides of port/path
-    #   all per-node metrics shall be 'recent' (oops, not smartctl!)
-    map: dict[str, object] = {
+    cmap: dict[str, object] = {
         'rules': alert_rules.allRules(ctx),
     }
     top = Path('build/scrape_config')
     for p in top.glob('*.yaml'):
-        map[str(p.relative_to(top))] = scrapeConfig(p)
-    replaceCmap("victoriametrics-config", map)
+        cmap[str(p.relative_to(top))] = scrapeConfig(p)
+    replaceCmap("victoriametrics-config", cmap)
+
+    # note: these will fail on first run, since you have to make config before
+    # you can launch the service for the first time. Also, these won't error if
+    # there are problems with the config. Watch the vmagent (etc) logs.
     refreshPodCmaps(firstPodName("app=victoriametrics-forever-vmagent"))
     refreshPodCmaps(firstPodName("app=victoriametrics-recent-vmagent"))