Skip to content

Skip deleted jobs in utask_main scheduling and enforce U24 nofile in CI - #5629

Open
hunsche wants to merge 2 commits into
masterfrom
fix/u24-scheduler-spec-and-nofile-ci
Open

hunsche wants to merge 2 commits into
masterfrom
fix/u24-scheduler-spec-and-nofile-ci

Conversation

@hunsche

@hunsche hunsche commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up hardening for Ubuntu 24.04 task scheduling and image build checks (Related: b/526881754):

  1. Skip deleted and unmapped jobs in create_utask_main_jobs (batch/service.py and k8s/service.py): _get_config_names omits tasks whose Job entity has been removed from Datastore or whose platform is unmapped, so indexing specs[(command, job_type)] directly raised KeyError (and K8s crashed on None instance_spec), aborting scheduling for all valid tasks in the same batch while leaving the stale message unacknowledged. Passing skip_unmapped=True for create_utask_main_jobs and guarding missing/unmapped specs logs a deduplicated warning and skips only the invalid job so valid tasks proceed and stale messages drain cleanly.
  2. Persist nofile soft limit in Ubuntu 24.04 PAM config and verify in CI: Adds * soft nofile 65535 and root soft nofile 65535 under /etc/security/limits.d/99-clusterfuzz-nofile.conf in the Ubuntu 24.04 base and immutable Dockerfiles, extracts docker/verify_ubuntu24_nofile.sh to assert ulimit -Sn >= 65535 across sudo -u clusterfuzz, sudo -u root, and start_clusterfuzz.sh independently during Ubuntu 24.04 image builds (docker/build.sh, docker/build-immutable.sh), and adds a Linux startup unit test (run_test.py).

Testing

  • butler.py format and butler.py lint
  • butler.py py_unittest -t core -p batch_service_test.py (22/22 passed)
  • butler.py py_unittest -t core -p k8s_service_test.py (9/9 passed)
  • butler.py py_unittest -t core -p run_test.py (5/5 passed)
  • Verified docker/verify_ubuntu24_nofile.sh (sudo -E -H -u clusterfuzz, sudo -E -H -u root, and start_clusterfuzz.sh without PAM override) in Docker on base:ubuntu-24-04

@hunsche
hunsche requested review from a team as code owners November 20, 2026 01:56
@hunsche
hunsche force-pushed the fix/u24-scheduler-spec-and-nofile-ci branch from 5dc32f5 to 0043de2 Compare November 25, 2026 16:21
@hunsche
hunsche force-pushed the fix/u24-scheduler-spec-and-nofile-ci branch from 0043de2 to 0a18091 Compare November 25, 2026 16:57

@ViniciustCosta ViniciustCosta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this into separate PR since the CI and the utask_main scheduling enhancements are unrelated?

Comment on lines 373 to 378
if instance_spec is None:
if skip_unmapped:
logs.warning(f'No batch mapping for {config_name} '
f'({task.command}, {task.job_type}).')
continue
raise ValueError(f'No mapping for {config_name}')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes behavior for unmapped platforms. Before, a missing mapping entry raised ValueError, remote_task_gate caught it and returned the tasks as uncreated, so they were retried. Now they're left out of the uncreated list, so schedule_utask_mains acks them and they're lost.

That's right for a deleted Job (permanent), but a missing mapping is a config problem (new platform, typo, bad config rollout) and would silently discard every utask_main for that platform with only a warning. Could we skip only tasks whose Job entity is gone, and keep returning unmapped specs as uncreated (or at least log them at error level)? Same for k8s/service.py L117-120.

Comment on lines +507 to +511
spec = specs.get((remote_task.command, remote_task.job_type))
if spec is None:
logs.warning('Skipping utask_main with missing batch spec: '
f'{remote_task.command}, {remote_task.job_type}.')
continue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code already skipped jobs missing from config_map with logs.error('Error on mapping the job'); the KeyError was only here. This PR lowers that to a warning (L364-368) and adds this per-task warning on top. seen_keys only dedups inside the specs builder, so N stale messages for one deleted job still log N warnings here, plus the error from _get_config_names. Suggest keeping a single error-level log per (command, job_type) and dropping this per-task warning (same in k8s/service.py L331-335).

RUN groupadd nopwsudo && \
echo "%nopwsudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/mysudoers
echo "%nopwsudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/mysudoers && \
printf '* soft nofile 65535\nroot soft nofile 65535\n' > /etc/security/limits.d/99-clusterfuzz-nofile.conf

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which path still needs the PAM limits file? Master already raises the soft limit after sudo: start_clusterfuzz.sh runs ulimit -Sn inside the sudo -u $USER bash -c (#5624), and ensure_open_file_limit in run.py/run_bot.py raises it again. Which process still reaches PAM with a 1024 soft limit? The verify script's third check even deletes this file to show start_clusterfuzz.sh works without it.

If there's a real path (e.g. sudo from the AFL launcher), please name it in a comment; otherwise I'd drop the file. 65535 is now hard-coded in ~6 places.

Comment on lines +26 to +27
COPY ${CLUSTERFUZZ_SOURCE_DIR}/docker/base/start_clusterfuzz.sh /data/start_clusterfuzz.sh
RUN printf '* soft nofile 65535\nroot soft nofile 65535\n' > /etc/security/limits.d/99-clusterfuzz-nofile.conf

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These images are FROM base:ubuntu-24-04 / chromium/base:ubuntu-24-04, so they already get /data/start_clusterfuzz.sh and the limits file. Copying them again means four Dockerfiles to keep in sync. Unless immutable builds can run on a stale base (worth a comment if so), can these lines go? Same for the chromium dev/internal immutable Dockerfiles.

self.mock.ensure_open_file_limit.assert_called_once_with()

@unittest.skipUnless(sys.platform.startswith('linux'), 'Linux-only script')
def test_start_clusterfuzz_script_raises_soft_nofile_after_sudo(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests a Docker shell script the PR doesn't change, from inside run.py's test file. It runs real sudo with preexec_fn, depends on hard-limit math and hard-codes REPO_ROOT_PARENT_DEPTH = 7. It skips on dev machines but runs as root in CI. verify_ubuntu24_nofile.sh already covers this inside the real image. Suggest removing it, along with the new imports and constants.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants