Skip to content

Conversation

kruskall
Copy link
Member

The zip task was relying on 'touch -d @seconds' to set the timestamp of
output files to allow reproducible builds.
'touch -d @seconds' is not POSIX compliant and the standard only supports
a subset of formats:

https://man7.org/linux/man-pages/man1/touch.1p.html

The standard way of doing it would be to use one of those format or just use
'touch -t TIME'.
Since SOURCE_DATE_EPOCH is providing seconds since epoch and we don't have a
standard way to convert them to a standard format used by touch, we rely on
'date' and use a fallback mechanism to try two different syntax:

  • Busybox and GNU coreutils date
  • BSD date

The zip task was relying on 'touch -d @seconds' to set the timestamp of
output files to allow reproducible builds.
'touch -d @seconds' is not POSIX compliant and the standard only supports
a subset of formats:

https://man7.org/linux/man-pages/man1/touch.1p.html

The standard way of doing it would be to use one of those format or just use
'touch -t TIME'.
Since SOURCE_DATE_EPOCH is providing seconds since epoch and we don't have a
standard way to convert them to a standard format used by touch, we rely on
'date' and use a fallback mechanism to try two different syntax:

- Busybox and GNU coreutils date
- BSD date
@github-actions github-actions bot added the aws-λ-extension AWS Lambda Extension label Aug 12, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-08-12T19:44:20.280+0000

  • Duration: 7 min 20 sec

Test stats 🧪

Test Results
Failed 0
Passed 130
Skipped 32
Total 162

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

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

Copy link
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! WFM on macos, and two runs of make build zip result in an identical "extension.zip".

The quote from https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html applies here:

It is like a set of trapezoidal building blocks, with no vertical or horizontal surfaces, like a language in which the simplest thought demands ornate constructions, useless particles and lengthy circumlocutions.

working with time is such a pain.

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 10 to +15
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)
DATE_FMT = +%Y%m%d%H%M.%S
# Fallback mechanism to support other systems:
# 1. 'date -d': Busybox and GNU coreutils.
# 2. 'date -r': BSD date. It does not support '-d'.
BUILD_DATE = $(shell date -u -d "@${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "${DATE_FMT}")
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's worth trying to adhere to SOURCE_DATE_EPOCH. This would be simpler by using the --date flag of git log:

BUILD_DATE = $(shell git log -1 --pretty=%cd --date=format:%Y%m%d%H%M.%S)

Copy link
Member Author

@kruskall kruskall Aug 15, 2022

Choose a reason for hiding this comment

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

I think we should still support SOURCE_DATE_EPOCH but that's a valid point.

Moreover avoiding to call date would increase compatibility since touch is POSIX compliant and git is required to build the extension.

I will merge this for now but we can iterate on it!

@kruskall kruskall merged commit e4785b5 into elastic:main Aug 15, 2022
@kruskall kruskall deleted the fix/reproducible-compat branch August 15, 2022 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-λ-extension AWS Lambda Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants