Skip to content

[HttpKernel] Make kernel build time optionally deterministic #26128

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

Merged
merged 1 commit into from
Feb 11, 2018
Merged

[HttpKernel] Make kernel build time optionally deterministic #26128

merged 1 commit into from
Feb 11, 2018

Conversation

lstrojny
Copy link
Contributor

@lstrojny lstrojny commented Feb 9, 2018

Q A
Branch? master for features / 2.7 up to 4.0 for bug fixes
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

As part of the effort to enable reproducible builds, this PR allows setting a deterministic build time for the dumped kernel. Parent issue is #25958.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

this is going to be fun to document :)
I'd suggest to open a doc issue/PR related to this ongoing work on reproducibility

@@ -717,6 +717,7 @@ protected function getKernelParameters()
'kernel.bundles_metadata' => $bundlesMetadata,
'kernel.charset' => $this->getCharset(),
'kernel.container_class' => $this->getContainerClass(),
'kernel.container_build_time' => time(),
Copy link
Member

Choose a reason for hiding this comment

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

Wait, this doesn't work: before this change, the container had always the same hash, thus was stored always in the same dir. Now that this param is time dependent - and since it's dumped into the container, this property is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean because kernel.container_build_time will be different for every request? That is indeed true but it’s only used in the dumper.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what I mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to just introduce a method that returns the build time. People who want to make it deterministic can hook their own getenv() magic in there.

@@ -855,6 +855,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
'as_files' => true,
'debug' => $this->debug,
'inline_class_loader_parameter' => \PHP_VERSION_ID >= 70000 && !$this->loadClassCache && !class_exists(ClassCollectionLoader::class, false) ? 'container.dumper.inline_class_loader' : null,
'build_time' => $this->getContainerBuildTime(),
Copy link
Member

Choose a reason for hiding this comment

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

instead of the method, what about adding the option only when a kernel.container_build_time parameter exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this?

@nicolas-grekas nicolas-grekas changed the title Make kernel build time optionally deterministic [HttpKernel] Make kernel build time optionally deterministic Feb 11, 2018
@nicolas-grekas nicolas-grekas modified the milestones: 4.1, 3.4 Feb 11, 2018
@nicolas-grekas
Copy link
Member

Thank you @lstrojny.

@nicolas-grekas nicolas-grekas merged commit 48e8249 into symfony:3.4 Feb 11, 2018
nicolas-grekas added a commit that referenced this pull request Feb 11, 2018
This PR was merged into the 3.4 branch.

Discussion
----------

Make kernel build time optionally deterministic

| Q             | A
| ------------- | ---
| Branch?       | master for features / 2.7 up to 4.0 for bug fixes <!-- see below -->
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

As part of the effort to enable reproducible builds, this PR allows setting a deterministic build time for the dumped kernel. Parent issue is #25958.

Commits
-------

48e8249 Make kernel build time optionally deterministic
@lstrojny lstrojny deleted the dev/deterministic-kernel-build-time branch February 13, 2018 16:41
This was referenced Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants