Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Add$kernel->getBuildDir() to separate it from the cache directory#36515
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| publicfunctiongetTmpDir() | ||
| { | ||
| // Returns $this->getCacheDir() for backward compatibility | ||
| return$this->getCacheDir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Here is the core of the PR :)
For backward compatibility, I return the current cache directory.
In future versions, this could be for examplevar/build. In the meantime, users can override this method to set it to a different path, for example/tmp.
Uh oh!
There was an error while loading.Please reload this page.
61bd29e tofee57fbCompare$kernel->getTmpDir() to separate it from the cache directory$kernel->getTmpDir() to separate it from the cache directoryjaviereguiluz commentedApr 22, 2020
This solution probably makes a lot of sense ... but at first seems confusing: Problem:
Solution:
|
mnapoli commentedApr 22, 2020
@javiereguiluz yes, this was brought up in#23354 (comment) and I think that's a valid alternative: keep cache as-is, introduce a new I'm waiting for feedback on this new approach, I started looking into it a pull request as well but haven't opened it yet. |
fabpot commentedAug 18, 2020
This is a good move IMHO. Reading the related issue, I think we should get the naming right. Keeping the |
$kernel->getTmpDir() to separate it from the cache directory$kernel->getBuildDir() to separate it from the cache directorymnapoli commentedAug 19, 2020
Great! I have updated the PR. Note that after struggling for a while I did not succeed running the tests locally ( Review is welcome! |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM (minor comment)
WDYT @symfony/mergers?
Uh oh!
There was an error while loading.Please reload this page.
stof commentedAug 20, 2020
@mnapoli are you using the |
weaverryan commentedAug 20, 2020
This makes a lot of sense to me. And the fact that the new Very nice! |
| } | ||
| $io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>',$kernel->getEnvironment(),var_export($kernel->isDebug(),true))); | ||
| $this->cacheClearer->clear($realBuildDir); |
ogizanagiAug 20, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Shouldn't this command avoid removing the build dir by default? What about adding a--build option?
For the ones not overridingKernelInterface::getBuildDir(), this option won't do anything more.
But for the ones overriding, you might want to call this command to clear the read-write cache, but not the read-only build dir, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
As a first step, we must clear everything like today.
mnapoli commentedAug 20, 2020
@stof thanks for the tip, I didn't. Still, when I use it the tests crash with:
Anyway, I don't really want to pollute the discussion with this. |
fabpot commentedAug 21, 2020
Thank you@mnapoli. |
Uh oh!
There was an error while loading.Please reload this page.
This PR was merged into the 5.2 branch.Discussion----------[FrameworkBundler] Fix cache:clear with buildDir| Q | A| ------------- | ---| Branch? | 5.2| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#39232| License | MIT| Doc PR |Since#36515 there are 2 caches dir `cacheDir` and `buildDir`. For BC reason both points to the same folders, but when app don't use the same folder, many thing are broken:This PR fixes several issues introduces by the above PR:- some files are persisted in the wrong folder (`App_KernelDevDebugContainerDeprecations.log`, `App_KernelDevDebugContainer.xml`)- LoggerDataCollector looks into cache_dir, while `Compiler.log` is written in build_dir and `Deprecations.log` were written in cache_dir before this PR- the logic that mirror cacheDir into buildDir at the end of CacheClearCommand does not make sens when `cache_dir` and `build_dir` are not identical.- Files generated in cacheDir are trashed at the end of CacheWarming (initial issue)Commits-------ea68966 Fix cache:clear with buildDir
This PR was squashed before being merged into the 4.x branch.Discussion----------Use buildDir for cacheFeature available since Symfony 5.2 -symfony/symfony#36515Commits-------9daaade Use buildDir for cache
Uh oh!
There was an error while loading.Please reload this page.
In order to support deploying on read-only filesystems (e.g. AWS Lambda in my case), I have started implementing#23354.
This introduces
$kernel->getBuildDir():$kernel->getBuildDir(): for cache that can be warmed and deployed as read-only (compiled container, annotations, etc.)$kernel->getCacheDir(): for cache that can be written at runtime (e.g. cache pools, session, profiler, etc.)I have probably missed some places or some behavior of Symfony that I don't know. Don't consider this PR perfect, but rather I want to help move things forward :)
TODO: