Skip to content

Commit

Permalink
Merge pull request #4585 from opensafely-core/evansd/replace-filesync…
Browse files Browse the repository at this point in the history
…-with-airlock

Point to Airlock for viewing log outputs
  • Loading branch information
evansd authored Sep 4, 2024
2 parents 4e5da5f + 438b49c commit a215c45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 39 deletions.
24 changes: 4 additions & 20 deletions jobserver/views/jobs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions templates/job/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,10 @@ <h1 class="min-w-0 text-3xl break-words md:text-4xl font-bold text-slate-900">

{% if log_path %}
<p class="text-slate-600">
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:
<pre class="text-slate-500 break-all whitespace-pre-wrap">{{ log_path }}</pre>
</p>
<p class="text-slate-600">
Alternatively, view the file on the {{ job.job_request.backend.name }} server at: <pre class="text-slate-500 break-all whitespace-pre-wrap">{{ log_path }}</pre>
</p>
{% endif %}
{% endif %}
</div>
{% /description_item %}

Expand Down
5 changes: 0 additions & 5 deletions templates/workspace/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ <h1 class="mb-2 text-3xl tracking-tight break-words font-bold text-slate-900 sm:

{% #card title="Releases" %}
{% #list_group small=True %}
{% #list_group_item href=workspace.get_files_url disabled=outputs.level_4.disabled %}
<span class="mr-2">Level 4 Outputs</span>
{% 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%}
Expand Down
9 changes: 1 addition & 8 deletions tests/unit/jobserver/views/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a215c45

Please sign in to comment.