feat(security): add operator rotation and recovery commands
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
+30
-10
@@ -8,10 +8,10 @@ from urllib.parse import urlencode
|
||||
from scripts.stand import compose
|
||||
|
||||
ENDPOINTS = {
|
||||
"prometheus": "http://prometheus:9090",
|
||||
"loki": "http://loki:3100",
|
||||
"tempo": "http://tempo:3200",
|
||||
"otel": "http://otel:13133",
|
||||
"prometheus": "https://prometheus:9900",
|
||||
"loki": "https://loki:3310",
|
||||
"tempo": "https://tempo:3320",
|
||||
"otel": "https://otel:13333",
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,20 @@ def fetch(service, path, *, params=None, json_result=True):
|
||||
if params:
|
||||
url += "?" + urlencode(params, doseq=True)
|
||||
code = (
|
||||
"import urllib.request; "
|
||||
f"r=urllib.request.urlopen(urllib.request.Request({url!r},headers={{'Accept':'application/json'}}),timeout=8); "
|
||||
f"import urllib.request; from src.security_probe import context; service={service!r}; "
|
||||
f"r=urllib.request.urlopen(urllib.request.Request({url!r},headers={{'Accept':'application/json'}}),timeout=8,context=context('operator' if 'otel' == service else 'grafana')); "
|
||||
"print(r.read().decode())"
|
||||
)
|
||||
text = compose("exec", "-T", "observer", "python", "-c", code)
|
||||
text = compose(
|
||||
"--profile",
|
||||
"operator",
|
||||
"run",
|
||||
"--rm",
|
||||
"--no-deps",
|
||||
"operator-probe",
|
||||
"-c",
|
||||
code,
|
||||
)
|
||||
return json.loads(text) if json_result else text
|
||||
|
||||
|
||||
@@ -50,14 +59,25 @@ def queries(expressions):
|
||||
for name, expression in expressions.items()
|
||||
}
|
||||
code = (
|
||||
"import json,urllib.request\n"
|
||||
"import json,urllib.request\nfrom src.security_probe import context\n"
|
||||
f"urls={urls!r}\n"
|
||||
"result={}\n"
|
||||
"for name,url in urls.items():\n"
|
||||
" with urllib.request.urlopen(url,timeout=8) as r: result[name]=json.load(r)['data']['result']\n"
|
||||
" with urllib.request.urlopen(url,timeout=8,context=context('grafana')) as r: result[name]=json.load(r)['data']['result']\n"
|
||||
"print(json.dumps(result))"
|
||||
)
|
||||
return json.loads(compose("exec", "-T", "observer", "python", "-c", code))
|
||||
return json.loads(
|
||||
compose(
|
||||
"--profile",
|
||||
"operator",
|
||||
"run",
|
||||
"--rm",
|
||||
"--no-deps",
|
||||
"operator-probe",
|
||||
"-c",
|
||||
code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def logs(trace_id, *, start=None):
|
||||
|
||||
Reference in New Issue
Block a user