Skip to content

Commit

Permalink
Pass request id to old_api.create_releaase
Browse files Browse the repository at this point in the history
This is more robust that attempting to retrieve the request id from
the release_json.
  • Loading branch information
rebkwok committed Jun 28, 2024
1 parent 8a754a6 commit 60eb553
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion airlock/business_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,10 @@ def release_files(self, release_request: ReleaseRequest, user: User):

filelist = old_api.create_filelist(file_paths, release_request)
jobserver_release_id = old_api.create_release(
release_request.workspace, filelist.json(), user.username
release_request.workspace,
release_request.id,
filelist.json(),
user.username,
)

for relpath, abspath in file_paths:
Expand Down
4 changes: 2 additions & 2 deletions old_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create_filelist(paths, release_request):
)


def create_release(workspace_name, release_json, username):
def create_release(workspace_name, release_request_id, release_json, username):
"""API call to job server to create a release."""
response = session.post(
url=f"{settings.AIRLOCK_API_ENDPOINT}/releases/workspace/{workspace_name}",
Expand All @@ -55,7 +55,7 @@ def create_release(workspace_name, release_json, username):
logger.error(
"%s Error creating release - %s - %s",
response.status_code,
release_json["airlock_id"],
release_request_id,
response.content.decode(),
)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_old_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_old_api_create_release(responses):

assert (
old_api.create_release(
"workspace_name", {"airlock_id": "jobserver-id"}, "testuser"
"workspace_name", "jobserver-id", {"airlock_id": "jobserver-id"}, "testuser"
)
== "jobserver-id"
)
Expand All @@ -39,7 +39,7 @@ def test_old_api_create_release_with_error(responses, caplog):
)
with pytest.raises(requests.exceptions.HTTPError):
old_api.create_release(
"workspace_name", {"airlock_id": "jobserver-id"}, "testuser"
"workspace_name", "jobserver-id", {"airlock_id": "jobserver-id"}, "testuser"
)
assert len(caplog.messages) == 1
log = caplog.messages[0]
Expand Down

0 comments on commit 60eb553

Please sign in to comment.