Commit 81f8013
authored
* fix(pkgmgr): address PR #561 review follow-ups
Closes #562
- activate() built the file-install-step symlink source from the raw,
un-rendered filename while the destination used the rendered path,
producing a dangling symlink for any package with a templated (e.g.
per-OS/ARCH) filename. Both now use the rendered path.
- PackageManager.Install() and Upgrade() never ran Package.validate()
before installing, so a malformed package (bad archive config,
missing docker image, etc.) skipped straight to install() instead of
failing with a clear validation error. Upgrade() in particular could
tear down the working installed version before hitting the failure.
- url-sourced file installs used context.Background() with no
deadline, leaving a stalled server able to hang the install
indefinitely despite the existing size cap.
- The tar.gz decompression cap was a fixed 512 MiB applied to the
whole archive, with no way for a package to raise it for a
legitimately large multi-arch/bundle release. Added an optional
archiveMaxSize file-install-step field (capped at 4 GiB) that raises
the effective decompression limit for that package's archive.
- Cleaned up stale doc comments and pre-existing (from #561) lines
over the 80-char guideline in pkgmgr/archive.go and its tests.
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
* fix(pkgmgr): address review feedback on PR #561 follow-ups
- TestUpgradeRejectsInvalidNewPackageVersion's upgrade-target package
had no filePath set, so Package.validate() rejected it on the
file-path check before ever reaching the missing content/source/url
check the test's comment describes. Set a valid filePath so the test
exercises the path it claims to.
- Documented that archiveMaxSize bounds cumulative decompressed data
for tar.gz/tgz, not just the selected entry (only ZIP's central
directory lets extraction skip decompressing non-matching entries).
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
* fix(pkgmgr): fix golangci-lint failures on archive extraction helpers
- gosec G115: guard extractZipFileWithLimit against a negative maxSize
before the int64 -> uint64 conversion used to compare against
UncompressedSize64. maxSize is always non-negative on every current
call path, but the linter can't prove that once it's a parameter
rather than a constant.
- unused: extractArchiveFile, extractZipFile, and extractTarGzFile were
only reachable from _test.go files after the archiveMaxSize refactor
routed production code through the ...WithLimit variants directly.
This repo's .golangci.yml sets run.tests: false, so the linter never
saw those test-only call sites. Removed the dead wrappers and updated
their test call sites to call the ...WithLimit functions directly
with maxArchiveEntrySize.
Verified with golangci-lint run ./... locally: 0 issues.
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
* fix(pkgmgr): validate the whole install/upgrade plan before mutating
- Install() and Upgrade() validated each resolved package one at a time,
inside the same loop that installs/uninstalls it. A resolver-ordered
plan with multiple entries (e.g. a requested package's dependencies,
or a new dependency pulled in by an upgrade) could partially apply:
earlier, valid entries would install and persist - or, on upgrade,
deactivate/uninstall their old version - before a later, invalid
entry in the same plan was ever rejected. Reproduced with a focused
probe (a "dep" that installs and persists before an invalid "app"
that depends on it is rejected) before fixing.
Both now validate every entry in the resolved plan upfront, before
any install/uninstall/deactivate work begins.
- The url-download-timeout test called install() synchronously, so a
regressed production timeout would hang the call forever (the test
server's handler only unblocks after install() returns) rather than
failing the test - confirmed by reverting the production fix and
measuring the test hang. Now runs install() in a goroutine under a
bounded watchdog and asserts the returned error is actually
context.DeadlineExceeded, not just any error.
Both new regression tests were verified to actually fail without their
corresponding fix (probed manually, then confirmed via the automated
test), then verified to pass once restored.
Addresses review feedback from @wolf31o2 on PR #586.
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
* fix(pkgmgr): render templated filename in uninstall(), not just install/activate
PackageInstallStepFile.uninstall() built the delete path from the raw,
un-rendered Filename while install() and activate() already used the
rendered path. For a package with a templated (e.g. per-OS/ARCH)
filename, os.Remove targeted a literal path like ".../{{ .System.OS
}}" that never existed, silently no-op'd on fs.ErrNotExist, and left
the real rendered file (e.g. binary-linux) behind.
This mattered most on upgrade: Upgrade() calls uninstallPackage with
keepData=true, which skips the whole-directory cleanup, so the
per-step uninstall() was the only thing that could have removed the
old version's rendered file - and didn't.
Render the filename the same way install()/activate() do before
building the delete path. Added a focused unit test on uninstall()
directly, and a production-shaped Install-then-Upgrade regression test
matching the exact scenario reported in review. Both verified to fail
without the fix and pass with it.
Addresses review feedback from @wolf31o2 on PR #586.
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
---------
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
1 parent 3bbc496 commit 81f8013
7 files changed
Lines changed: 927 additions & 82 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
41 | 58 | | |
42 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
43 | 66 | | |
44 | 67 | | |
45 | 68 | | |
| |||
51 | 74 | | |
52 | 75 | | |
53 | 76 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
58 | 83 | | |
59 | 84 | | |
60 | 85 | | |
| 86 | + | |
61 | 87 | | |
62 | 88 | | |
63 | 89 | | |
64 | | - | |
| 90 | + | |
65 | 91 | | |
66 | | - | |
| 92 | + | |
67 | 93 | | |
68 | 94 | | |
69 | 95 | | |
70 | 96 | | |
71 | 97 | | |
72 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
73 | 109 | | |
74 | 110 | | |
75 | 111 | | |
| |||
85 | 121 | | |
86 | 122 | | |
87 | 123 | | |
88 | | - | |
| 124 | + | |
89 | 125 | | |
90 | 126 | | |
91 | 127 | | |
92 | | - | |
| 128 | + | |
93 | 129 | | |
94 | 130 | | |
95 | 131 | | |
96 | 132 | | |
97 | 133 | | |
98 | 134 | | |
99 | 135 | | |
100 | | - | |
| 136 | + | |
101 | 137 | | |
102 | 138 | | |
103 | 139 | | |
104 | 140 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 141 | | |
114 | 142 | | |
115 | 143 | | |
| |||
140 | 168 | | |
141 | 169 | | |
142 | 170 | | |
143 | | - | |
| 171 | + | |
144 | 172 | | |
145 | 173 | | |
146 | 174 | | |
147 | | - | |
| 175 | + | |
148 | 176 | | |
149 | 177 | | |
150 | 178 | | |
151 | 179 | | |
152 | 180 | | |
153 | | - | |
| 181 | + | |
154 | 182 | | |
155 | 183 | | |
156 | 184 | | |
| |||
216 | 244 | | |
217 | 245 | | |
218 | 246 | | |
219 | | - | |
220 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
221 | 251 | | |
222 | 252 | | |
223 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
117 | | - | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
134 | | - | |
| 139 | + | |
| 140 | + | |
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
| |||
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
160 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
161 | 172 | | |
162 | 173 | | |
163 | 174 | | |
| |||
170 | 181 | | |
171 | 182 | | |
172 | 183 | | |
173 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
174 | 189 | | |
175 | 190 | | |
176 | 191 | | |
| |||
190 | 205 | | |
191 | 206 | | |
192 | 207 | | |
193 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
194 | 214 | | |
195 | 215 | | |
196 | 216 | | |
| |||
203 | 223 | | |
204 | 224 | | |
205 | 225 | | |
206 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
207 | 232 | | |
208 | 233 | | |
209 | 234 | | |
| |||
228 | 253 | | |
229 | 254 | | |
230 | 255 | | |
231 | | - | |
232 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
233 | 264 | | |
234 | 265 | | |
235 | 266 | | |
| |||
241 | 272 | | |
242 | 273 | | |
243 | 274 | | |
244 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
245 | 281 | | |
246 | 282 | | |
247 | 283 | | |
| |||
263 | 299 | | |
264 | 300 | | |
265 | 301 | | |
266 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
267 | 309 | | |
268 | 310 | | |
269 | 311 | | |
| |||
0 commit comments