~comcloudway/builds.sr.ht

1b706b4b6535e0b394e8815dea3f014ed08c5a40 — Conrad Hoffmann 1 year, 3 months ago c02243f
Use correct internal URL for fetching logs

In a setup where internal traffic is meant to stay internal (i.e. the
`internal-origin` config is used) fetching logs is currently broken. The
logs are served by the api component, but as is the request will be sent
to the Python frontend.

Fix this by using the value of `api-origin`, just falling back to
`get_origin` if that is not set. This is the same technique already
employed in the Python GraphQL client.

Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>
1 files changed, 1 insertions(+), 1 deletions(-)

M buildsrht/blueprints/jobs.py
M buildsrht/blueprints/jobs.py => buildsrht/blueprints/jobs.py +1 -1
@@ 488,7 488,7 @@ def job_by_id(username, job_id):
                set_cache(cachekey, timedelta(days=2), json.dumps(log))
        logs.append(log)
        return log["more"]
    origin = get_origin("builds.sr.ht")
    origin = cfg("builds.sr.ht", "api-origin", default=get_origin("builds.sr.ht"))
    log_url = f"{origin}/query/log/{job.id}/log"
    if get_log(log_url, None, job.status):
        for task in sorted(job.tasks, key=lambda t: t.id):