Skip to content

Commit

Permalink
include tracking id in audit logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rstijerina committed Nov 18, 2024
1 parent dfb0fa6 commit 78490c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
27 changes: 23 additions & 4 deletions designsafe/apps/workspace/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,10 @@ def select(self, client, request):
"""Returns detailed information for a given job uuid"""

job_uuid = request.GET.get("uuid")
data = client.jobs.getJob(jobUuid=job_uuid)
data = client.jobs.getJob(
jobUuid=job_uuid,
headers={"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"},
)

return data

Expand All @@ -584,6 +587,7 @@ def listing(self, client, request):
skip=skip,
orderBy="lastUpdated(desc),name(asc)",
select="allAttributes",
headers={"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"},
**kwargs,
)
if isinstance(data, list):
Expand Down Expand Up @@ -626,6 +630,7 @@ def search(self, client, request):
orderBy="lastUpdated(desc),name(asc)",
request_body={"search": sql_queries},
select="allAttributes",
headers={"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"},
)
return {"listing": data, "reachedEnd": len(data) < int(limit)}

Expand All @@ -645,7 +650,10 @@ def delete(self, request, *args, **kwargs):
)
tapis = request.user.tapis_oauth.client
job_uuid = request.GET.get("uuid")
data = tapis.jobs.hideJob(jobUuid=job_uuid)
data = tapis.jobs.hideJob(
jobUuid=job_uuid,
headers={"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"},
)
return JsonResponse(
{
"status": 200,
Expand Down Expand Up @@ -755,6 +763,9 @@ def _submit_job(self, request, body, tapis, username):
tapis.files.mkdir(
systemId=exec_system_id,
path=f"{system['home_dir'].format(tasdir)}/.tap",
headers={
"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"
},
)

# Add webhook subscription for job status updates
Expand All @@ -771,7 +782,10 @@ def _submit_job(self, request, body, tapis, username):
]

logger.info(f"user: {username} is submitting job: {job_post}")
response = tapis.jobs.submitJob(**job_post)
response = tapis.jobs.submitJob(
**job_post,
headers={"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"},
)
return response

def post(self, request, *args, **kwargs):
Expand All @@ -797,7 +811,12 @@ def post(self, request, *args, **kwargs):
status=400,
)
tapis_operation = getattr(tapis.jobs, operation)
response = tapis_operation(jobUuid=job_uuid)
response = tapis_operation(
jobUuid=job_uuid,
headers={
"X-Tapis-Tracking-ID": f"portals.{request.session.session_key}"
},
)

else:
# submit job
Expand Down
4 changes: 2 additions & 2 deletions designsafe/settings/common_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
'metrics': {
'format': '[METRICS] %(levelname)s %(module)s %(name)s.%(funcName)s:%(lineno)s:'
' %(message)s user=%(user)s ip=%(ip)s agent=%(agent)s sessionId=%(sessionId)s op=%(operation)s'
' info=%(info)s timestamp=%(asctime)s portal=designsafe tenant=designsafe'
' info=%(info)s timestamp=%(asctime)s trackingId=portal.%(sessionId)s portal=designsafe tenant=designsafe'
},
},
'handlers': {
Expand Down Expand Up @@ -508,7 +508,7 @@
ALLOCATIONS_TO_EXCLUDE = (
os.environ.get("ALLOCATIONS_TO_EXCLUDE", "").split(",")
if os.environ.get("ALLOCATIONS_TO_EXCLUDE")
else ["DesignSafe-DCV"]
else ["DesignSafe-DCV,DesignSafe-Corral"]
)


Expand Down

0 comments on commit 78490c6

Please sign in to comment.