From 89b4d75eb215a84504907984c983cd597dbee2d4 Mon Sep 17 00:00:00 2001
From: David Evans
Date: Tue, 3 Sep 2024 17:25:25 +0100
Subject: [PATCH 1/2] Point to Airlock for viewing log outputs
There's no point linking directly to the relevant Airlock URL because we
don't expect users to be accessing Job Server from within Level 4 going
forward, and even you have Airlock open in a VM you can't copy/paste
URLs across.
Instead we link to the Airlock docs and describe the location of the
file. This replaces both the link the output viewer and the reference to
the old "Level 4 file sync" directory.
Previously we restricted these links to only show for the TPP backend,
but on the assumption that we will be running an instance of Airlock for
every backend I have removed this restriction.
---
jobserver/views/jobs.py | 24 ++++--------------------
templates/job/detail.html | 9 +++------
tests/unit/jobserver/views/test_jobs.py | 9 +--------
3 files changed, 8 insertions(+), 34 deletions(-)
diff --git a/jobserver/views/jobs.py b/jobserver/views/jobs.py
index 6adb6f300..46a7d7fb0 100644
--- a/jobserver/views/jobs.py
+++ b/jobserver/views/jobs.py
@@ -1,12 +1,9 @@
-import os
-
from django.contrib import messages
from django.core.exceptions import MultipleObjectsReturned
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.views.generic import RedirectView, View
-from furl import furl
from .. import honeycomb
from ..authorization import CoreDeveloper, has_permission, has_role, permissions
@@ -69,22 +66,10 @@ def get(self, request, *args, **kwargs):
# (previously status_tools). It isn't ideal to have here but until we
# have more than one backend-specific error code it makes sense to keep
# things together.
- log_path = ""
- log_path_url = ""
- if job.job_request.backend.slug == "tpp" and job.status_code == "nonzero_exit":
- log_path = os.path.join(
- job.job_request.backend.parent_directory,
- job.job_request.workspace.name,
- "metadata",
- f"{job.action}.log",
- )
- url = (
- furl(job.job_request.workspace.get_files_url())
- / "metadata"
- / f"{job.action}.log"
- )
- url.path.normalize()
- log_path_url = url.url
+ if job.status_code == "nonzero_exit":
+ log_path = f"metadata/{job.action}.log"
+ else:
+ log_path = ""
honeycomb_links = {}
if honeycomb_can_view_links:
@@ -128,7 +113,6 @@ def get(self, request, *args, **kwargs):
"cancellation_requested": job.action in job.job_request.cancelled_actions,
"job": job,
"log_path": log_path,
- "log_path_url": log_path_url,
"object": job,
"user_can_cancel_jobs": can_cancel_jobs,
"view": self,
diff --git a/templates/job/detail.html b/templates/job/detail.html
index 9ec30aed1..016a3effd 100644
--- a/templates/job/detail.html
+++ b/templates/job/detail.html
@@ -142,13 +142,10 @@
{% if log_path %}
- You can check the log output in the {% link text="outputs viewer" href=log_path_url %}
- {% pill text="VPN Required" variant="primary" %}
+ If you have VPN access you can view the log output in {% link text="Airlock" href="https://docs.opensafely.org/using-opensafely/releasing-research-outputs/releasing-with-airlock/" append_after="," %} in the workspace file:
+
{{ log_path }}
-
- Alternatively, view the file on the {{ job.job_request.backend.name }} server at:
{{ log_path }}
-
- {% endif %}
+ {% endif %}
{% /description_item %}
diff --git a/tests/unit/jobserver/views/test_jobs.py b/tests/unit/jobserver/views/test_jobs.py
index 1df872089..73f08bae9 100644
--- a/tests/unit/jobserver/views/test_jobs.py
+++ b/tests/unit/jobserver/views/test_jobs.py
@@ -297,14 +297,7 @@ def test_jobdetail_with_nonzero_exit_code(rf):
)
assert response.status_code == 200
- assert (
- response.context_data["log_path"]
- == f"/var/test/{job_request.workspace.name}/metadata/my_action.log"
- )
- assert (
- response.context_data["log_path_url"]
- == f"{job.job_request.workspace.get_files_url()}metadata/my_action.log"
- )
+ assert response.context_data["log_path"] == "metadata/my_action.log"
def test_jobdetail_with_partial_identifier_failure(rf):
From 438b49cbb44739a582e51756560a40706d65e267 Mon Sep 17 00:00:00 2001
From: David Evans
Date: Wed, 4 Sep 2024 16:44:57 +0100
Subject: [PATCH 2/2] Remove Level 4 outputs link
---
templates/workspace/detail.html | 5 -----
1 file changed, 5 deletions(-)
diff --git a/templates/workspace/detail.html b/templates/workspace/detail.html
index b4b5fa3b2..055765404 100644
--- a/templates/workspace/detail.html
+++ b/templates/workspace/detail.html
@@ -256,11 +256,6 @@ Level 4 Outputs
- {% pill text="VPN Required" variant="primary" %}
- {% /list_group_item%}
-
{% #list_group_item href=workspace.get_releases_url disabled=outputs.released.disabled %}
Released Outputs
{% /list_group_item%}