Commit 5b7f6aa
authored
feat(batch): Add dynamic OS image selection for jobs (#4993)
## What this PR does
This PR introduces the core logic in ClusterFuzz to support running jobs
on different base OS images, as outlined in the Ubuntu 24.04 migration
plan. It enables the platform to dynamically schedule jobs on different
OS versions based on project-level configuration.
## Why this PR is important
This change is a prerequisite for migrating ClusterFuzz jobs from the
EOL Ubuntu 20.04 to Ubuntu 24.04. By making the platform OS-aware, we
can perform a gradual, safe migration without disrupting existing
fuzzing jobs. This implementation specifically addresses the
requirements of **b/441792600**.
## How the changes were implemented
This PR includes three main code changes:
1. **`data_types.py`**: The `OssFuzzProject` model is extended with a
`base_os_version` string property. This allows the Datastore to persist
the desired OS version for each OSS-Fuzz project.
2. **`cron/project_setup.py`**: The project synchronization cron job is
updated. It now reads the `base_os_version` field from a project's
`project.yaml` file (in the `oss-fuzz` repository) and saves it to the
corresponding `OssFuzzProject` entity in the Datastore.
3. **`google_cloud_utils/batch.py`**: The batch job creation logic is
refactored to be backward-compatible and OS-aware:
* It now fetches the `base_os_version` for the project associated with a
task.
* It attempts to find a corresponding image in a new
`versioned_docker_images` map in the batch configuration (`batch.yaml`).
* If a versioned image is not found (for legacy projects or during the
transition), it safely falls back to using the existing `docker_image`
key, ensuring no disruption.
## Related Task
* **Task:** [b/441792600](b/441792600)1 parent 5dcfd3e commit 5b7f6aa
File tree
6 files changed
+105
-6
lines changed- .gemini
- src/clusterfuzz/_internal
- cron
- datastore
- google_cloud_utils
- tests
- appengine/handlers/cron
- core/google_cloud_utils
6 files changed
+105
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
| |||
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
559 | 564 | | |
560 | 565 | | |
561 | 566 | | |
| |||
568 | 573 | | |
569 | 574 | | |
570 | 575 | | |
571 | | - | |
| 576 | + | |
| 577 | + | |
572 | 578 | | |
573 | 579 | | |
574 | 580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
948 | 948 | | |
949 | 949 | | |
950 | 950 | | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
951 | 954 | | |
952 | 955 | | |
953 | 956 | | |
| |||
1467 | 1470 | | |
1468 | 1471 | | |
1469 | 1472 | | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
1470 | 1476 | | |
1471 | 1477 | | |
1472 | 1478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
271 | 282 | | |
272 | | - | |
| 283 | + | |
273 | 284 | | |
274 | 285 | | |
275 | 286 | | |
| |||
308 | 319 | | |
309 | 320 | | |
310 | 321 | | |
311 | | - | |
| 322 | + | |
| 323 | + | |
312 | 324 | | |
313 | 325 | | |
314 | 326 | | |
315 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
316 | 339 | | |
317 | 340 | | |
318 | 341 | | |
| |||
332 | 355 | | |
333 | 356 | | |
334 | 357 | | |
335 | | - | |
| 358 | + | |
336 | 359 | | |
337 | 360 | | |
338 | 361 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
| 634 | + | |
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
| |||
644 | 646 | | |
645 | 647 | | |
646 | 648 | | |
| 649 | + | |
647 | 650 | | |
648 | 651 | | |
649 | 652 | | |
| |||
655 | 658 | | |
656 | 659 | | |
657 | 660 | | |
| 661 | + | |
658 | 662 | | |
659 | 663 | | |
660 | 664 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
151 | 209 | | |
152 | 210 | | |
153 | 211 | | |
| |||
0 commit comments