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

ostree commit hash is different on remote than on the local machine #10

Open
davisRoman opened this issue May 30, 2023 · 3 comments
Open

Comments

@davisRoman
Copy link

After ostree-push runs, the commit hash on the remote server is different than the commit on the local machine. This is very confusing to users. Is it supposed to be this way? Is there a way to push a commit hash that doesn't get changed on the remote ostree server?

@dbnicholson
Copy link
Owner

They are different because a new commit object is created on the server. There are 2 reasons for this:

  1. The commit hash depends on the parent commit's hash. In order to maintain history on the remote server, the existing commit on the ref is used as the parent for the newly created commit. Typically you wouldn't have any history on the builder, although it is possible.
  2. OSTree commits have 2 fields in the commit metadata used for binding them to specific refs and repos. These might not be correct in the uploaded commit.

In the past I had some code that tried harder to reuse the uploaded commit as is if it already had the appropriate metadata but it never quite worked right. So, at the moment there isn't a way to maintain the commit hash, but I can try to look at that again if it's important to you.

@davisRoman
Copy link
Author

davisRoman commented May 30, 2023

Your explanation makes sense but perhaps it'll help if I explain my end goal. We have a jenkins CI/CD pipeline that runs yocto ( a linux distribution generator) and when it's done building, it generates an ostree commit with hash X and this gets displayed on our Jenkins dashboard (to correlate jenkins build number to ostree hashes). As a final stage in our pipeline, we run ostree-push to copy the commit to our OTA deployment server but my surprise, the commit gets stored as hash Y. So just to double confirm, is there anything on my end that I cab do differently in order for the commits not to change or is the only remedy to make some modification on the tool itself? If a modification is in fact needed on the ostree-push command itself, then yes, it would really help a lot if you could help us with this. Thank you.

@dbnicholson
Copy link
Owner

What I'd suggest in the short term is that you query the current revision after pushing and use that in the Jenkins description. There are 2 ways I'd do it.

  1. ostree pull --commit-metadata-only "$remote" "$ref" && rev=$(ostree rev-parse "$remote:$ref"). This will work on very old ostree versions.
  2. rev=$(ostree remote refs --revision "$remote" | awk "\$1 == \"$ref\" {print \$2}"). The --revision option for remote refs is only in ostree 2023.1, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants