Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add rerun for savedsearch
  • Loading branch information
xqi-splunk committed Jun 13, 2025
commit af111b78e86c38c449c9db03f0e1548dd0ab4643
16 changes: 15 additions & 1 deletion contentctl/objects/correlation_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# Suppress logging by default; enable for local testing
ENABLE_LOGGING = True
LOG_LEVEL = logging.DEBUG
LOG_PATH = "correlation_search.log"
LOG_PATH = "correlation_search_test2.log"


class SavedSearchKeys(StrEnum):
Expand Down Expand Up @@ -934,10 +934,10 @@

# keep track of time slept and number of attempts for exponential backoff (base 2)
elapsed_sleep_time = 0
num_tries = 0

Check failure on line 937 in contentctl/objects/correlation_search.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F841)

contentctl/objects/correlation_search.py:937:9: F841 Local variable `num_tries` is assigned to but never used

# set the initial base sleep time
time_to_sleep = TimeoutConfig.BASE_SLEEP

Check failure on line 940 in contentctl/objects/correlation_search.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F841)

contentctl/objects/correlation_search.py:940:9: F841 Local variable `time_to_sleep` is assigned to but never used

try:
# first make sure the indexes are currently empty and the detection is starting from a disabled state
Expand Down Expand Up @@ -1004,7 +1004,7 @@
current_turn += 1

self.logger.info(
f"Skipping sleeping time for testing purposes"

Check failure on line 1007 in contentctl/objects/correlation_search.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F541)

contentctl/objects/correlation_search.py:1007:25: F541 f-string without any placeholders
)

if current_turn > 3:
Expand All @@ -1013,6 +1013,20 @@
self.logger.info(f"Waiting {wait_time}s before retry {current_turn}...")

wait_time = min(wait_time * 2, max_wait)

# Rerun the search job
job = self.dispatch()
self.logger.info(f"Force running detection '{self.name}' with job ID: {job.sid}")

time_to_execute = 0

# Check if the job is finished
while not job.is_done():
self.logger.info(f"Job {job.sid} is still running...")
time.sleep(1)
time_to_execute += 1

self.logger.info(f"Job {job.sid} has finished running in {time_to_execute} seconds.")

# reset the result to None on each loop iteration
result = None
Expand Down
Loading