From bd3e01331693dba23b0ac19fee5cc73a391f3a22 Mon Sep 17 00:00:00 2001 From: Ivan Barba Date: Wed, 4 Mar 2026 20:56:15 +0000 Subject: [PATCH 1/3] Swarming: Creates Feature Flag to control its usage --- src/clusterfuzz/_internal/base/feature_flags.py | 2 ++ src/clusterfuzz/_internal/swarming/__init__.py | 5 +++-- .../_internal/tests/core/datastore/feature_flag_test.py | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/clusterfuzz/_internal/base/feature_flags.py b/src/clusterfuzz/_internal/base/feature_flags.py index d66f4145a9c..9598fb46925 100644 --- a/src/clusterfuzz/_internal/base/feature_flags.py +++ b/src/clusterfuzz/_internal/base/feature_flags.py @@ -35,6 +35,8 @@ class FeatureFlags(Enum): PREPROCESS_QUEUE_SIZE_LIMIT = 'preprocess_queue_size_limit' + SWARMING_TASKS = 'swarming_tasks' + @property def flag(self): """Get the feature flag.""" diff --git a/src/clusterfuzz/_internal/swarming/__init__.py b/src/clusterfuzz/_internal/swarming/__init__.py index 1c387122fac..7cf5eeba649 100644 --- a/src/clusterfuzz/_internal/swarming/__init__.py +++ b/src/clusterfuzz/_internal/swarming/__init__.py @@ -19,6 +19,7 @@ from google.protobuf import json_format from clusterfuzz._internal.base import utils +from clusterfuzz._internal.base.feature_flags import FeatureFlags from clusterfuzz._internal.config import local_config from clusterfuzz._internal.datastore import data_types from clusterfuzz._internal.google_cloud_utils import credentials @@ -33,10 +34,10 @@ def _requires_gpu() -> bool: return bool(utils.string_is_true(requires_gpu)) -def is_swarming_task(command: str, job_name: str): +def is_swarming_task(command: str, job_name: str) -> bool: """Returns True if the task is supposed to run on swarming.""" job = data_types.Job.query(data_types.Job.name == job_name).get() - if not job or not _requires_gpu(): + if not job or not _requires_gpu() or not FeatureFlags.SWARMING_TASKS.enabled: return False try: _get_new_task_spec(command, job_name, '') diff --git a/src/clusterfuzz/_internal/tests/core/datastore/feature_flag_test.py b/src/clusterfuzz/_internal/tests/core/datastore/feature_flag_test.py index afa9de6dd43..6c0c6387728 100644 --- a/src/clusterfuzz/_internal/tests/core/datastore/feature_flag_test.py +++ b/src/clusterfuzz/_internal/tests/core/datastore/feature_flag_test.py @@ -53,3 +53,11 @@ def test_get_and_set(self): self.assertEqual(feature_flags.FeatureFlags.TEST_FLOAT_FLAG.content, 1.23) self.assertEqual(feature_flags.FeatureFlags.TEST_FLOAT_FLAG.string_value, 'checker') + + def test_not_found_in_db(self): + """Test that a feature flag returns empty or False values when not found in the DB.""" + self.assertFalse(feature_flags.FeatureFlags.TEST_FLAG.enabled) + self.assertIsNone(feature_flags.FeatureFlags.TEST_FLAG.flag) + self.assertIsNone(feature_flags.FeatureFlags.TEST_FLAG.content) + self.assertEqual(feature_flags.FeatureFlags.TEST_FLAG.description, '') + self.assertEqual(feature_flags.FeatureFlags.TEST_FLAG.string_value, '') From 880492e0c8f1fbb722b6f69c75bd66a055795fe4 Mon Sep 17 00:00:00 2001 From: Ivan Barba Date: Thu, 5 Mar 2026 17:41:43 +0000 Subject: [PATCH 2/3] Moves Feature Flag validation to be done earlier --- src/clusterfuzz/_internal/swarming/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/clusterfuzz/_internal/swarming/__init__.py b/src/clusterfuzz/_internal/swarming/__init__.py index 7cf5eeba649..5cb44dab2f5 100644 --- a/src/clusterfuzz/_internal/swarming/__init__.py +++ b/src/clusterfuzz/_internal/swarming/__init__.py @@ -36,8 +36,10 @@ def _requires_gpu() -> bool: def is_swarming_task(command: str, job_name: str) -> bool: """Returns True if the task is supposed to run on swarming.""" + if not not FeatureFlags.SWARMING_TASKS.enabled: + return False job = data_types.Job.query(data_types.Job.name == job_name).get() - if not job or not _requires_gpu() or not FeatureFlags.SWARMING_TASKS.enabled: + if not job or not _requires_gpu(): return False try: _get_new_task_spec(command, job_name, '') From 9a6d79e524f3050077c79fccd2eb1475b502a74a Mon Sep 17 00:00:00 2001 From: Ivan Barba Date: Thu, 5 Mar 2026 17:49:03 +0000 Subject: [PATCH 3/3] Fix Typo, renames feature flag --- src/clusterfuzz/_internal/base/feature_flags.py | 2 +- src/clusterfuzz/_internal/swarming/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clusterfuzz/_internal/base/feature_flags.py b/src/clusterfuzz/_internal/base/feature_flags.py index 9598fb46925..9bea8c41f97 100644 --- a/src/clusterfuzz/_internal/base/feature_flags.py +++ b/src/clusterfuzz/_internal/base/feature_flags.py @@ -35,7 +35,7 @@ class FeatureFlags(Enum): PREPROCESS_QUEUE_SIZE_LIMIT = 'preprocess_queue_size_limit' - SWARMING_TASKS = 'swarming_tasks' + SWARMING_REMOTE_EXECUTION = 'swarming_remote_execution' @property def flag(self): diff --git a/src/clusterfuzz/_internal/swarming/__init__.py b/src/clusterfuzz/_internal/swarming/__init__.py index 5cb44dab2f5..f049091ee66 100644 --- a/src/clusterfuzz/_internal/swarming/__init__.py +++ b/src/clusterfuzz/_internal/swarming/__init__.py @@ -36,7 +36,7 @@ def _requires_gpu() -> bool: def is_swarming_task(command: str, job_name: str) -> bool: """Returns True if the task is supposed to run on swarming.""" - if not not FeatureFlags.SWARMING_TASKS.enabled: + if not FeatureFlags.SWARMING_REMOTE_EXECUTION.enabled: return False job = data_types.Job.query(data_types.Job.name == job_name).get() if not job or not _requires_gpu():