Skip to content

Conversation

donoghuc
Copy link
Member

@donoghuc donoghuc commented Sep 2, 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

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
Copy link
Contributor

github-actions bot commented Sep 2, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Contributor

mergify bot commented Sep 2, 2025

This pull request does not have a backport label. Could you fix it @donoghuc? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

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

@@ -669,7 +669,7 @@ namespace "artifact" do
elsif stat.symlink?
tar.symlink(path_in_tar, File.readlink(path), :mode => stat.mode)
else
tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size) do |io|
tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size, :mtime => stat.mtime&.to_i || 0) do |io|
Copy link
Member Author

Choose a reason for hiding this comment

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

For the reviewer here is the source for this method https://github.com/halostatue/minitar/blob/a531136b17b9efdddf0a0f39537845b454c2371e/lib/minitar/writer.rb#L104-L177

Idea is that to avoid it defaulting to nil (and resulting in a 0 for linux epoch time) we explicitly pass through the mtime of the file on the builder (or 0 if for some reason that cant be computed).

One use case #17925 on upgrade is relying on rsync defaults where it would be convenient that for each logstash release all files in an artifact have a "newer" mtime than the previous release. I believe this would ensure that.

Copy link
Member

Choose a reason for hiding this comment

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

Should we then just do :mtime => stat.mtime&.to_i || Time.now.to_i ? seems better than epoch, there's already some expectation that dates of files in the archive will be similar to the date of when the files were put into the archive.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

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

Successfully merging this pull request may close these issues.

3 participants