Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding child commit to repository fails with "parent commit could not be loaded" #279

Closed
achilleas-k opened this issue Aug 21, 2023 · 1 comment · Fixed by #281
Closed
Assignees

Comments

@achilleas-k
Copy link

achilleas-k commented Aug 21, 2023

Version
pulpcore version: 3.31.0
pulp-ostree version: 2.1.1

Describe the bug
Importing a child commit to a repository fails with The parent commit '<PARENT COMMIT ID>' could not be loaded, even though the parent commit is already in the repository.

To Reproduce
I have an ostree repository in Pulp with a single commit under the ref test/iot. I created a child commit using osbuild-composer.

Status checks:

  1. Check pulp repository commit ID with curl
$ curl http://localhost:8080/pulp/content/pulptest/refs/heads/test/iot
86b2ffaf4d90b23bea660d9bb9fd5416baafd2df56331e92f4a715abb3e27ca2

with ostree summary

$ mkdir repo
$ cd repo
$ ostree init --repo .
$ ostree remote add test http://localhost:8080/pulp/content/pulptest/
$ ostree remote summary test
* test/iot
    Latest Commit (18.9 kB):
      86b2ffaf4d90b23bea660d9bb9fd5416baafd2df56331e92f4a715abb3e27ca2
    Version (ostree.commit.version): 38
    Timestamp (ostree.commit.timestamp): 2023-08-21T14:07:21+02

Last-Modified (ostree.summary.last-modified): 2023-08-21T14:10:14+02
Repository Mode (ostree.summary.mode): archive-z2
Has Tombstone Commits (ostree.summary.tombstone-commits): No
ostree.summary.indexed-deltas: true
  1. Check the child commit ID and parent

With commit.tar being the child tarball built by image builder:

$ mkdir child
$ tar xvf commit.tar -C child
$ ostree show --repo ./child/repo test/iot
commit 89b1f4ae4a587212a2bd366058607ecd92f129c8ddd9cf5f5f50ca3819e0ce4d
Parent:  86b2ffaf4d90b23bea660d9bb9fd5416baafd2df56331e92f4a715abb3e27ca2
ContentChecksum:  5aaeab2ecae71861e61ace7e32ca0ee8e85e1824b566cb979fd612889f5079e1
Date:  2023-08-21 12:22:50 +0000
Version: 38
(no subject)
  1. Upload child commit to pulp.
$ pulp -v ostree repository import-all --file ./commit.tar --name test-repo --repository_name repo
repositories_ostree_ostree_list : get http://localhost:8080/pulp/api/v3/repositories/ostree/ostree/?name=test-repo&offset=0&limit=1
Response: 200
artifacts_list : get http://localhost:8080/pulp/api/v3/artifacts/?sha256=c1992bc1350cca8246f7bc8d9152a3d52c033470d56ba85ae7f4c160440fdb53&offset=0&limit=1
Response: 200
Artifact already exists.
repositories_ostree_ostree_import_all : post http://localhost:8080/pulp/api/v3/repositories/ostree/ostree/018a17fe-f2c9-74b4-a6eb-5b3325fadb4e/import_all/
Response: 202
tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
Started background task /pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
.tasks_read : get http://localhost:8080/pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/
Response: 200
Error: Task /pulp/api/v3/tasks/018a1836-9086-7184-a831-7760e9dc69d1/ failed: 'The parent commit '86b2ffaf4d90b23bea660d9bb9fd5416baafd2df56331e92f4a715abb3e27ca2' could not be loaded'

Expected behavior
The child commit should import successfully and become the new commit for the test/iot ref.

Additional context
The following appears in the pulp container log

pulp [46ae9e063c7f48f3ba203de5ac4e632b]: pulpcore.tasking.tasks:INFO: Task 018a1836-9086-7184-a831-7760e9dc69d1 failed (The parent commit '86b2ffaf4d90b23bea660d9bb9fd5416baafd2df56331e92f4a715abb3e27ca2' could not be loaded)
pulp [46ae9e063c7f48f3ba203de5ac4e632b]: pulpcore.tasking.tasks:INFO:   File "/usr/local/lib/python3.8/site-packages/pulpcore/tasking/tasks.py", line 65, in _execute_task
    result = func(*args, **kwargs)

  File "/usr/local/lib/python3.8/site-packages/pulp_ostree/app/tasks/importing.py", line 49, in import_all_refs_and_commits
    return dv.create()

  File "/usr/local/lib/python3.8/site-packages/pulpcore/plugin/stages/declarative_version.py", line 161, in create
    loop.run_until_complete(pipeline)

  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()

  File "/usr/local/lib/python3.8/site-packages/pulpcore/plugin/stages/api.py", line 220, in create_pipeline
    await asyncio.gather(*futures)

  File "/usr/local/lib/python3.8/site-packages/pulpcore/plugin/stages/api.py", line 41, in __call__
    await self.run()

  File "/usr/local/lib/python3.8/site-packages/pulp_ostree/app/tasks/importing.py", line 301, in run
    parsed_result = await self.parse_ref(name, ref_commit_checksum)

  File "/usr/local/lib/python3.8/site-packages/pulp_ostree/app/tasks/importing.py", line 114, in parse_ref
    raise ValueError(
@achilleas-k
Copy link
Author

achilleas-k commented Aug 21, 2023

Here's a standalone reproducer:

#!/usr/bin/env bash

set -euo pipefail

workdir=$(mktemp -d)
cd "${workdir}"

# prepare pulp
pulp ostree repository create --name test
pulp ostree distribution create --name test --repository test --base-path test

# first commit
mkdir "${workdir}/first"
cd "${workdir}/first"
ostree --repo="${workdir}/first/repo" init --mode=archive
mkdir "${workdir}/first/files"
echo "one" > files/file.txt
commit=$(ostree commit --repo "${workdir}/first/repo" --branch ostree-main "${workdir}/first/files/")

cd "${workdir}/first"
tar czvf repo.tar "repo/"

# first upload
pulp ostree repository import-all --name test --file repo.tar --repository_name repo

# second commit
mkdir "${workdir}/second"
cd "${workdir}/second"
mkdir files
echo "two" > files/file2.txt
ostree --repo="${workdir}/second/repo" init --mode=archive
ostree commit --repo repo --branch ostree-main files/ --parent="${commit}"
tar czvf repo.tar repo/

# second upload
echo "Uploading and importing second repo"
pulp ostree repository import-all --name test --file repo.tar --repository_name repo  # Error: Task /pulp/api/v3/tasks/.../ failed: 'The parent commit '...' could not be loaded'

@lubosmj lubosmj self-assigned this Aug 28, 2023
@pulpbot pulpbot moved this to In Progress in RH Pulp Kanban board Aug 28, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Aug 28, 2023
@pulpbot pulpbot moved this from In Progress to Needs review in RH Pulp Kanban board Aug 28, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Aug 28, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Aug 28, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Sep 4, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Sep 4, 2023
lubosmj added a commit to lubosmj/pulp_ostree that referenced this issue Sep 4, 2023
lubosmj added a commit that referenced this issue Sep 6, 2023
@pulpbot pulpbot moved this from Needs review to Done in RH Pulp Kanban board Sep 6, 2023
patchback bot pushed a commit that referenced this issue Sep 11, 2023
lubosmj added a commit that referenced this issue Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants