Commit 7e57438
fix(server): k8s patch_sandbox_metadata correctly deletes keys and returns post-patch state (#899)
* fix(server): k8s patch_sandbox_metadata correctly deletes keys and returns post-patch state
Two bugs in KubernetesSandboxService.patch_sandbox_metadata caused the
nightly k8s mini E2E test_02_metadata_filter_and_logic to fail:
1. JSON merge patch (RFC 7396) on metadata.labels merges keys recursively
— keys absent from the patch body are kept. The previous code computed
the desired final labels dict (with deleted keys removed) and sent it,
so deleted keys were never actually removed on the API server.
2. After the PATCH, the code re-fetched the workload via
_get_workload_or_404, which goes through K8sClient.get_custom_object
that prefers the informer cache. The informer is eventually consistent,
so the read could land before the watch event arrived and return the
pre-patch labels.
Fix both by:
- Building the merge-patch body with explicit None for deleted keys.
- Using the API server's PATCH response (returned from patch_labels)
directly, instead of re-reading via the cache.
WorkloadProvider.patch_labels now accepts Dict[str, Optional[str]] and
returns the patched workload dict.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore(ci): touch trigger comment to run k8s mini E2E on this PR
The k8s-nightly-build workflow only runs on PRs that touch one of its
trigger paths. This PR fixes server-side k8s logic but does not modify
those paths, so add a date stamp to the existing trigger comment to
include this PR in the matrix.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent a0f66f3 commit 7e57438
4 files changed
Lines changed: 80 additions & 11 deletions
File tree
- scripts
- server
- opensandbox_server/services/k8s
- tests/k8s
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
794 | 803 | | |
795 | | - | |
| 804 | + | |
796 | 805 | | |
797 | 806 | | |
798 | | - | |
| 807 | + | |
799 | 808 | | |
800 | 809 | | |
801 | 810 | | |
802 | 811 | | |
803 | 812 | | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | 813 | | |
810 | 814 | | |
811 | 815 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
207 | 213 | | |
208 | | - | |
| 214 | + | |
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1297 | 1297 | | |
1298 | 1298 | | |
1299 | 1299 | | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
0 commit comments