-
Notifications
You must be signed in to change notification settings - Fork 314
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
fix(bazel): Always disable the disk cache #8811
Conversation
1aa30ed
to
17f0735
Compare
Reading up on [1], it may be better to always disable the disk cache. From the comments I guess that it This can be done by:
|
@fviernau As I mentioned in the issue, you need to specify the parameter (temp disk cache or no disk cache) to EVERY Bazel command run by ORT, even the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8811 +/- ##
=========================================
Coverage 67.79% 67.79%
Complexity 1164 1164
=========================================
Files 243 243
Lines 7711 7711
Branches 861 861
=========================================
Hits 5228 5228
Misses 2127 2127
Partials 356 356
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Did I miss any bazel command invocations? |
@@ -0,0 +1 @@ | |||
common --disk_cache=/non-existing-dir |
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.
Missing line at the end
@@ -20,6 +20,7 @@ | |||
package org.ossreviewtoolkit.plugins.packagemanagers.bazel |
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.
Commit message: fixes the related issue.
As I said |
I agree that always disabling the disk cache seems like the best approach. |
I am able to run |
This is really strange.
|
@fviernau As a sidenote, please note that there is Maybe we can use @haikoschol Would it be ok? |
17f0735
to
60f1cd1
Compare
Maybe due to different implicit working directories? |
I've run bazel in the directory in which the |
@@ -171,7 +171,10 @@ class Bazel( | |||
}.getOrNull() | |||
|
|||
private fun getDependencyGraph(projectDir: File, depDirectives: Map<String, BazelDepDirective>): Set<Scope> { | |||
val modGraphProcess = run("mod", "graph", "--output", "json", workingDir = projectDir) | |||
val modGraphProcess = run( | |||
"mod", "graph", "--output", "json", "--disk_cache", "\"\"", workingDir = projectDir |
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.
I did my tests with run("mod", "graph", "--output", "json", "--disk_cache=", workingDir = projectDir)
and it worked fine.
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.
So you mean to remove the "dummy" "\"\""
argument in favor of adding a =
after the option name?
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.
Yes
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.
I changed it as @nnobelis has put it.
I don't see why not. Weird that I didn't discover BTW, I run Bazel through Bazelisk on my laptop, which seems to intercept the
And
|
60f1cd1
to
c727623
Compare
Thanks guys, very helpful! I've added a commit to switch to |
c727623
to
63a30bd
Compare
"transformBazelVersion()" should { | ||
"remove everything except for the version number" { | ||
val bazelVersionOutput = """ | ||
Bazelisk version: development |
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.
I even put the Bazelisk output in the test, even though I didn't use it in the Docker image. Surprising that this ever worked. 😅
override fun getVersionArguments() = "version" | ||
|
||
override fun transformVersion(output: String) = transformBazelVersion(output) | ||
override fun transformVersion(output: String) = output.removePrefix("bazel ") |
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.
Nit: Maybe say "Using the default bazel --version
..." to better explain why this works by basically just removing code.
@@ -171,7 +171,10 @@ class Bazel( | |||
}.getOrNull() | |||
|
|||
private fun getDependencyGraph(projectDir: File, depDirectives: Map<String, BazelDepDirective>): Set<Scope> { | |||
val modGraphProcess = run("mod", "graph", "--output", "json", workingDir = projectDir) | |||
val modGraphProcess = run( | |||
"mod", "graph", "--output", "json", "--disk_cache", "\"\"", workingDir = projectDir |
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.
So you mean to remove the "dummy" "\"\""
argument in favor of adding a =
after the option name?
Using the default `bazel --version` is simpler and more resilient in case of mis-configuration, such as the disk cache pointing to a non-existing directory. Signed-off-by: Frank Viernau <[email protected]>
When the disk-cache is set via `.bazelrc` to a non-existing directory, `bazel mod graph` fails with a complaint about permissions, which in turn makes the analysis fail. The disk cache is a build cache which seems to target speeding up builds in case of code changes (such as switching branches) [1]. During ORT analysis code changes are not in play, so the disk cache seems to be of little use anyway. Simply disable it to avoid running into that permission issue. Fixes: #8802. [1] https://stackoverflow.com/questions/61282419/bazel-how-outputroot-and-disk-cache-relate-regarding-local-caching Signed-off-by: Frank Viernau <[email protected]>
63a30bd
to
5a6dbac
Compare
See individual commits.