Skip to content

feat: use HistoryTimestamp, if set, for oci-archive entries#6023

Merged
openshift-merge-bot[bot] merged 2 commits intocontainers:mainfrom
aeijdenberg:usehistorytimestampinociarchive
Mar 25, 2025
Merged

feat: use HistoryTimestamp, if set, for oci-archive entries#6023
openshift-merge-bot[bot] merged 2 commits intocontainers:mainfrom
aeijdenberg:usehistorytimestampinociarchive

Conversation

@aeijdenberg
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR passes the existing HistoryTimetamp option, if set, to the CopyOptions passed to the image/v5 library, which in turn uses this for timestamps for some destinations, specifically oci-archive.

How to verify it

Before this change, this command will produce different output on each run (provided each run is at least 1 second apart):

$ ./bin/buildah build -f <(echo 'FROM scratch') --tag=oci-archive:oci.tar --timestamp 0 &>/dev/null && sha256sum oci.tar
182557b969fb24723b29e18770a2add930115492b4b267bb0847cecc14b47647  oci.tar
$ ./bin/buildah build -f <(echo 'FROM scratch') --tag=oci-archive:oci.tar --timestamp 0 &>/dev/null && sha256sum oci.tar
cb7ffa809d00485700d207ea291c8be8939b5596c9d04deeeacf7e26beb0e7aa  oci.tar

After this change, the same output is produced each time:

$ ./bin/buildah build -f <(echo 'FROM scratch') --tag=oci-archive:oci.tar --timestamp 0 &>/dev/null && sha256sum oci.tar
b5706eba1022041e2eeceada4f0da68ccd002c768ddb9e28e4dd5ca422f73cd1  oci.tar
$ ./bin/buildah build -f <(echo 'FROM scratch') --tag=oci-archive:oci.tar --timestamp 0 &>/dev/null && sha256sum oci.tar
b5706eba1022041e2eeceada4f0da68ccd002c768ddb9e28e4dd5ca422f73cd1  oci.tar

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

I'm guessing we would normally wait for a new version of github.com/containers/image/v5 to be released before bumping?

Does this PR introduce a user-facing change?

The --timestamp option, if set, is now passed through to a destination of --tag=oci-archive: and is applied to the timestamp of entries in the tar archive.

@openshift-ci openshift-ci Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 4, 2025
@aeijdenberg
Copy link
Copy Markdown
Contributor Author

This is the 3rd part of 3 PRs - it relies on the following already merged PRs in dependent libraries, which is why it bumps the versions of each:
containers/storage#2259
containers/image#2730

@nalind
Copy link
Copy Markdown
Member

nalind commented Mar 4, 2025

I'm guessing we would normally wait for a new version of github.com/containers/image/v5 to be released before bumping?

Yeah, normally a bot opens those when it spots a new upstream release, and I try to discourage updating to non-tagged versions of dependencies that tag their releases. Are you sure a version bump was necessary here? That new DestinationTimestamp option appears to be in containers/image v5.34.1, which was the version that was being pulled in before the current version of this PR attempted to bump it.

Undoing the dependency bumps will cut the number of files this PR touches down significantly, making this much easier to review. I'm pretty sure the validation hooks will complain about there not being a new test to ensure that the new change produces the desired effect, but you've got most of what that test would need to do already written in the description.

@aeijdenberg aeijdenberg force-pushed the usehistorytimestampinociarchive branch from 91f0fe8 to aaad080 Compare March 5, 2025 08:03
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@aeijdenberg
Copy link
Copy Markdown
Contributor Author

Yeah, normally a bot opens those when it spots a new upstream release, and I try to discourage updating to non-tagged versions of dependencies that tag their releases. Are you sure a version bump was necessary here? That new DestinationTimestamp option appears to be in containers/image v5.34.1, which was the version that was being pulled in before the current version of this PR attempted to bump it.

I didn't see it in v5.34.1 (at least it didn't build for me). While that release was cut chronologically after DestinationTimestamp was added, it looks like they did so from a release branch, so we might need to wait for their next bump to get this change.

Undoing the dependency bumps will cut the number of files this PR touches down significantly, making this much easier to review. I'm pretty sure the validation hooks will complain about there not being a new test to ensure that the new change produces the desired effect, but you've got most of what that test would need to do already written in the description.

Yep, it's a 3 line change without the dependency bump. I've added a test (first time seeing bats so let me know if I've done it badly), and separated the commits.

First time contributing to this project, so figured I'd get the PR open and in shape while we wait for the upstream library's next release. Appreciate your time in looking at it.

@nalind
Copy link
Copy Markdown
Member

nalind commented Mar 5, 2025

I didn't see it in v5.34.1 (at least it didn't build for me). While that release was cut chronologically after DestinationTimestamp was added, it looks like they did so from a release branch, so we might need to wait for their next bump to get this change.

Ugh, you're right, I must've been misreading the git history.

Yep, it's a 3 line change without the dependency bump. I've added a test (first time seeing bats so let me know if I've done it badly), and separated the commits.

Nope, the test looks good. Thanks!

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2025
@aeijdenberg
Copy link
Copy Markdown
Contributor Author

Will wait to rebase until v5.35 (presumably) is released for https://github.com/containers/image

@nalind
Copy link
Copy Markdown
Member

nalind commented Mar 24, 2025

It looks like #6073 bumped us to using a commit on main anyway - any chance you'd like to rebase without the bits that touch go.mod/go.sum/vendor?

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
@aeijdenberg aeijdenberg force-pushed the usehistorytimestampinociarchive branch from aaad080 to 9b41f3c Compare March 25, 2025 07:15
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 25, 2025
@aeijdenberg
Copy link
Copy Markdown
Contributor Author

It looks like #6073 bumped us to using a commit on main anyway - any chance you'd like to rebase without the bits that touch go.mod/go.sum/vendor?

Done, thanks.

Comment thread tests/bud.bats Outdated
run_buildah build -f <(echo 'FROM scratch') --tag=oci-archive:${outpath}.c --timestamp 1

# should be different
! diff "${outpath}.a" "${outpath}.b"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a warning reported by OpenScanHub. Is it a real bug?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you're quite right. I'd tested the 2nd part (which was the main test) but didn't notice this failed to fail. I've fixed as per one of the suggestions in https://bats-core.readthedocs.io/en/stable/gotchas.html#my-negated-statement-e-g-true-does-not-fail-the-test-even-when-it-should

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. In the future please check the results from osh-diff-scan job submitted through Packit.

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
@nalind
Copy link
Copy Markdown
Member

nalind commented Mar 25, 2025

Thanks!
/approve
/lgtm

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aeijdenberg, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit 243d897 into containers:main Mar 25, 2025
37 checks passed
@stale-locking-app stale-locking-app Bot locked as resolved and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved kind/feature Categorizes issue or PR as related to a new feature. lgtm locked - please file new issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants