Repository navigation
[Swarming] Dispatch each utask_main Pub/Sub queue independently in run_bot - #5639
JuanMBriones wants to merge 1 commit into
Conversation
41c8985 to
dabdde9
Compare
dabdde9 to
8e3410d
Compare
smolkaj
left a comment
There was a problem hiding this comment.
Thanks for the PR! A few questions/nits.
|
|
||
| def get_utask_mains(queue_name: str) -> List[PubSubTask]: | ||
| def get_utask_mains(queue_name: str, | ||
| pull_seconds: int = UTASK_QUEUE_PULL_SECONDS |
There was a problem hiding this comment.
Add documentation for the arguments
| SUBQUEUE_IDENTIFIER = ':' | ||
|
|
||
| UTASK_QUEUE_PULL_SECONDS = 150 | ||
| SWARMING_UTASK_QUEUE_PULL_SECONDS = 30 |
| pub_sub_task_queue.SWARMING_UTASK_MAIN_QUEUE.name) | ||
| logs.info(f'Found {len(swarming_utask_mains)} swarming utask mains.') | ||
| utask_mains.extend(swarming_utask_mains) | ||
| def _schedule_utask_main_queue(queue_name: str, |
There was a problem hiding this comment.
Add documentation for arguments
| utask_mains = tasks.get_utask_mains(queue_name) | ||
| else: | ||
| utask_mains = tasks.get_utask_mains(queue_name, pull_seconds=pull_seconds) | ||
| except RuntimeError as e: |
There was a problem hiding this comment.
IIUC, this is to avoid the scheduling bot from failing with an error if a queue doesn't exist.
Which seems fair, but with this change we are introducing a new silent failure, i feel like its better that a CF bot crashes loudly when a queue doesn't exists rather than failing silently to schedule things.
Mainly because, if i have a brand new CF instance i would prefeer to it not work because my queues are not well defined, rather than seeing no 'failures' nor tasks being scheduled, and having to dig in the logs to find out why
There was a problem hiding this comment.
What's our plan for validating these changes? Both for this PR and the PR chain in general, since I suspect you may not be able to validate things one-by-one.
Please also document the plan in the PR description.
…n_bot Refactor schedule_utask_mains() to pull, lease, and dispatch each utask_main queue independently so platform-specific Swarming queues (such as utask_main-swarming-mac-arm64) cannot block each other or push leased messages past Pub/Sub's 600s ack deadline (b/517517107). Changes: * Add SWARMING_UTASK_QUEUE_PULL_SECONDS = 30 and an optional pull_seconds parameter to tasks.get_utask_mains(). * Extract _schedule_utask_main_queue() in run_bot.py and iterate over pub_sub_task_queue.get_all_swarming_utask_main_queues(), reusing a single RemoteTaskGate instance and catching RuntimeError for unprovisioned subscriptions during staged rollouts. * Update and expand schedule_utask_mains unit tests in run_bot_test.py. Tests: * python butler.py py_unittest -t core -p run_bot_test.py Bug: 565469156 Signed-off-by: Manuel Briones <manuelbriones@google.com>
8e3410d to
4ee51f4
Compare
Why we need this change?
Previously,
schedule_utask_mains()inrun_bot.pypulled messages fromutask_mainandutask_main-swarmingsequentially (each waiting up to150s), combined all tasks into a single list, and only then leased and dispatched them together. With per-platform Swarming queues (utask_main-swarming+utask_main-swarming-mac-arm64, per go/queuescf4macarm64), that combined loop creates three production risks:150sper additional queue pushes messages toward Pub/Sub's 600s ack deadline and lets one platform stall another.utask_main-swarming-mac-arm64raisesRuntimeError, which would abort dispatch for existing queues.RemoteTaskGateper queue is avoidable overhead.This PR (Part 2 of 4, consumer first) refactors
schedule_utask_mains()to pull, lease, and dispatch each queue independently using a30spull window for Swarming queues while gracefully skipping unprovisioned subscriptions — making it safe to land before any producers publish toutask_main-swarming-mac-arm64.Code Changes
SWARMING_UTASK_QUEUE_PULL_SECONDS = 30and an optionalpull_secondsparameter totasks.get_utask_mains()inbase/tasks/__init__.py(defaulting toUTASK_QUEUE_PULL_SECONDS = 150for non-Swarming queues)._schedule_utask_main_queue()insrc/python/bot/startup/run_bot.pyto pull, lease, and dispatch each queue independently, reusing a singleRemoteTaskGateinstance and catchingRuntimeErrorto log and skip unprovisioned subscriptions during staged rollouts.pub_sub_task_queue.get_all_swarming_utask_main_queues()whenSWARMING_REMOTE_EXECUTIONis enabled.schedule_utask_mainsunit tests inrun_bot_test.py(including missing-subscription tolerance).Tests
python butler.py py_unittest -t core -p run_bot_test.pyBug: 565469156
Stack created with GitHub Stacks CLI • Give Feedback 💬