Skip to content
36 changes: 36 additions & 0 deletions fridge-job-api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,42 @@ async def get_workflows(
return extract_argo_workflows(r.json())


@app.get("/workflows/{namespace}/{workflow_name}/log", tags=["Argo Workflows"])
async def get_workflow_log(
namespace: str,
workflow_name: str,
pod_name: str | None = None,
container_name: str = "main",
verified: Annotated[bool, "Verify the request with basic auth"] = Depends(
verify_request
),
):
params = {
"podName": pod_name or workflow_name,
"logOptions.container": container_name,
}

r = requests.get(
f"{ARGO_SERVER}/api/v1/workflows/{namespace}/{workflow_name}/log",
verify=VERIFY_TLS,
headers={"Authorization": f"Bearer {argo_token()}"},
params=params,
stream=True,
)
if r.status_code != 200:
raise HTTPException(
status_code=r.status_code, detail=parse_argo_error(r.json())
)

lines = []
for line in r.iter_lines():
if line:
parsed = json.loads(line)
if "result" in parsed:
lines.append(parsed["result"].get("content", ""))
return {"podName": workflow_name, "log": "\n".join(lines)}


@app.get("/workflows/{namespace}/{workflow_name}", tags=["Argo Workflows"])
async def get_single_workflow(
namespace: Annotated[str, "The namespace to list workflows from"],
Expand Down
14 changes: 13 additions & 1 deletion infra/fridge/isolated-cluster/components/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ def __init__(
"update",
],
),
PolicyRuleArgs(
api_groups=[""],
resources=[
"pods",
"pods/log",
],
verbs=[
"get",
"list",
"watch",
],
),
],
opts=child_opts,
)
Expand All @@ -122,7 +134,7 @@ def __init__(
opts=child_opts,
)

CustomResource(
self.minio_policy = CustomResource(
resource_name="minio-policy-readwrite",
api_version="sts.min.io/v1alpha1",
kind="PolicyBinding",
Expand Down
Loading