Commit af7bc1f
fix: skip vulnerability scanning for packages that failed to build
Root cause: When multiple packages depend on the same package (e.g., api/go:lib),
and that package's build fails, the build lock mechanism causes a race condition:
1. Goroutine A obtains the lock and starts building the shared dependency
2. Goroutine B waits on the lock
3. If Goroutine A's build fails, it releases the lock and returns an error
4. Goroutine B wakes up, sees the lock is released, and returns nil (success)
5. The error propagates up through Goroutine A's dependency chain only
6. If the target package's dependency chain goes through Goroutine B, the
main build 'succeeds' even though the dependency failed
7. Vulnerability scanning runs and fails because the package isn't in cache
This fix:
- Passes the package build status map to vulnerability scanning
- Only scans packages with status PackageBuilt or PackageDownloaded
- Skips packages that failed verification, download, or build
- Logs which packages are skipped and why
This prevents fatal errors in vulnerability scanning when a dependency build
fails in a parallel goroutine. The build will still fail if the dependency
error propagates through the main dependency chain, but vulnerability scanning
won't cause an additional confusing error.
Fixes the issue in gitpod-next PR #11869 where api/go:lib build failed in a
parallel goroutine, but the main build continued and vulnerability scanning
crashed trying to scan a package that wasn't in cache.
Co-authored-by: Ona <no-reply@ona.com>1 parent 75fa386 commit af7bc1f
2 files changed
+31
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
751 | 753 | | |
752 | | - | |
| 754 | + | |
753 | 755 | | |
754 | 756 | | |
755 | 757 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
| |||
88 | 101 | | |
89 | 102 | | |
90 | 103 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
94 | 108 | | |
95 | 109 | | |
96 | 110 | | |
| |||
194 | 208 | | |
195 | 209 | | |
196 | 210 | | |
| 211 | + | |
| 212 | + | |
197 | 213 | | |
198 | 214 | | |
199 | 215 | | |
| |||
202 | 218 | | |
203 | 219 | | |
204 | 220 | | |
205 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
206 | 229 | | |
207 | 230 | | |
208 | 231 | | |
| |||
0 commit comments