Skip to content

[9.0] (backport #18091) Preserve mtime explicitly when creating tar artifacts#18111

Merged
donoghuc merged 3 commits into9.0from
mergify/bp/9.0/pr-18091
Sep 4, 2025
Merged

[9.0] (backport #18091) Preserve mtime explicitly when creating tar artifacts#18111
donoghuc merged 3 commits into9.0from
mergify/bp/9.0/pr-18091

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Sep 3, 2025

Release notes

Improvement to logstash release artifacts file metadata: mtime is preserved when buiilding tar archives

What does this PR do?

When building tar archives, explicitly set mtime. This avoids losing that information in the minitar Writer.add_file_simple method
https://github.com/halostatue/minitar/blob/a531136b17b9efdddf0a0f39537845b454c2371e/lib/minitar/writer.rb#L139

Why is it important/What is the impact to the user?

Files containing mtime 0 lead to undesireable behavior in some use cases #17925 and do not show any clues to modification time. Avoiding setting mtime to 0 in many cases will help provide artifacts with the least amount of surprise to users.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Related issues


This is an automatic backport of pull request #18091 done by [Mergify](https://mergify.com).
* Preserve mtime explicitly when creating tar artifacts

When building tar archives, explicitly set mtime. This avoids losing that
information in the minitar `Writer.add_file_simple` method
 https://github.com/halostatue/minitar/blob/a531136b17b9efdddf0a0f39537845b454c2371e/lib/minitar/writer.rb#L139

* Better default for mtime

If for some reason we cant get a time from a File object (very unlikely)
a better default is Time.now rather than 0.

* Update rakelib/artifacts.rake

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>

---------

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
(cherry picked from commit d9b95bf)

# Conflicts:
#	rakelib/artifacts.rake
@mergify mergify bot added backport conflicts Detected git conflicts labels Sep 3, 2025
@mergify
Copy link
Contributor Author

mergify bot commented Sep 3, 2025

Cherry-pick of d9b95bf has failed:

On branch mergify/bp/9.0/pr-18091
Your branch is up to date with 'origin/9.0'.

You are currently cherry-picking commit d9b95bfd.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   rakelib/artifacts.rake

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

donoghuc and others added 2 commits September 4, 2025 10:35
* Ensure any file object in a tar archive has an mtime

Following up on #18091, when minitar
writes a directory or symlink it also needs explicit mtime. After inspecting
artifacts built from #18019 we see some other missing mtimes. This commit
ensures that information is explicitly passed to the minitar writer.

* Update rakelib/artifacts.rake

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>

---------

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
@elastic-sonarqube
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @donoghuc

@donoghuc donoghuc merged commit 36b0d53 into 9.0 Sep 4, 2025
12 checks passed
@donoghuc donoghuc deleted the mergify/bp/9.0/pr-18091 branch September 4, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport conflicts Detected git conflicts

2 participants