Skip to content

Commit

Permalink
backend: correctly obtain information about a publication
Browse files Browse the repository at this point in the history
The previous code "worked" only by an accident. Previously we called
the publication endpoint without a trailing slash (changed in d8013c),
which caused some weird redirect and returned a list of all
publications, not the one created publication that I expected.

We need to manually query the publication href from the submitted
task.
  • Loading branch information
FrostyX committed Jul 7, 2024
1 parent 8b41d48 commit 90ca16e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/copr_backend/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def get_distribution(self, name):
url += self._urlencode({"name": name, "offset": 0, "limit": 1})
return requests.get(url, **self.request_params)

def get_task(self, task):
"""
Get a detailed information about a task
"""
url = self.config["base_url"] + task
return requests.get(url, **self.request_params)
def _urlencode(self, query):
"""
Join a dict into URL query string but don't encode special characters
Expand Down
9 changes: 8 additions & 1 deletion backend/copr_backend/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ def publish_repository(self, chroot, **kwargs):
repository, response.text)
return False

publication = response.json()["results"][0]["pulp_href"]
task = response.json()["task"]
response = self.client.get_task(task)
if not response.ok:
self.log.error("Failed to get Pulp task %s because of %s",
task, response.text)
return False

publication = response.json()["created_resources"][0]
distribution_name = self._distribution_name(chroot)
distribution = self._get_distribution(chroot)

Expand Down

0 comments on commit 90ca16e

Please sign in to comment.