feat: Improve OS version filtering for Pub/Sub tasks #5026
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Summary:
This PR addresses a flaw in the client-side OS version filtering for Pub/Sub tasks. Legacy bots, which do not have the
BASE_OS_VERSIONenvironment variable set, were not correctly skipping tasks intended for specific, newer OS versions. This could lead to bots attempting to execute incompatible tasks, causing errors and wasting resources, particularly during OS version migrations.This change makes the task handling more resilient by ensuring that bots only process tasks compatible with their environment.
Changes:
_filter_task_for_os_mismatch: The core filtering logic insrc/clusterfuzz/_internal/base/tasks/__init__.pyhas been updated. It now correctly skips a task if the incoming message has abase_os_versionattribute and the bot's own OS version is either different or not set (None).src/clusterfuzz/_internal/tests/core/base/tasks/tasks_test.pyhave been updated to validate the corrected logic and ensure there are no regressions.Testing:
All changes are covered by unit tests. The relevant test suite passes successfully.