-
Notifications
You must be signed in to change notification settings - Fork 62
Boefjes combined schedulers integration #4015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jpbruinsslot
merged 11 commits into
poc/mula/combined-schedulers
from
feat/boefje/combined-schedulers-integration
Jan 15, 2025
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6cb4cb0
Changes for boefjes to integrate with combined schedulers
jpbruinsslot 4c042f7
Merge branch 'poc/mula/combined-schedulers' into feat/boefje/combined…
jpbruinsslot defa125
Precommit
jpbruinsslot d3524cb
Update tests
jpbruinsslot 46c3a38
Update tests
jpbruinsslot af19161
Update tests
jpbruinsslot f5062ab
Fix test
jpbruinsslot 5ea4817
Precommit
jpbruinsslot 18548f8
Update test_api.py
jpbruinsslot 8b89f88
Merge branch 'poc/mula/combined-schedulers' into feat/boefje/combined…
jpbruinsslot f79e570
Merge branch 'poc/mula/combined-schedulers' into feat/boefje/combined…
jpbruinsslot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,42 +81,28 @@ def run(self, queue_type: WorkerManager.Queue) -> None: | |
raise | ||
|
||
def _fill_queue(self, task_queue: Queue, queue_type: WorkerManager.Queue) -> None: | ||
if task_queue.qsize() > self.settings.pool_size: | ||
time.sleep(self.settings.worker_heartbeat) | ||
return | ||
logger.debug("Popping from queue %s", queue_type.value) | ||
|
||
try: | ||
queues = self.scheduler_client.get_queues() | ||
except HTTPError: | ||
# Scheduler is having issues, so make note of it and try again | ||
logger.exception("Getting the queues from the scheduler failed") | ||
time.sleep(self.settings.poll_interval) # But not immediately | ||
response = self.scheduler_client.pop_item(queue_type.value) | ||
except (HTTPError, ValidationError): | ||
logger.exception("Popping task from scheduler failed, sleeping 10 seconds") | ||
time.sleep(10) | ||
return | ||
|
||
# We do not target a specific queue since we start one runtime for all organisations | ||
# and queue ids contain the organisation_id | ||
queues = [q for q in queues if q.id.startswith(queue_type.value) and q.size > 0] | ||
|
||
logger.debug("Found queues: %s", [queue.id for queue in queues]) | ||
|
||
all_queues_empty = True | ||
|
||
for queue in queues: | ||
logger.debug("Popping from queue %s", queue.id) | ||
|
||
try: | ||
p_item = self.scheduler_client.pop_item(queue.id) | ||
except (HTTPError, ValidationError): | ||
logger.exception("Popping task from scheduler failed, sleeping 10 seconds") | ||
time.sleep(10) | ||
continue | ||
|
||
if not p_item: | ||
logger.debug("Queue %s empty", queue.id) | ||
continue | ||
# TODO: check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check what kind of response the scheduler gives when the queue is empty and handle this. |
||
if not response: | ||
logger.debug("Queue %s empty", queue_type.value) | ||
time.sleep(10) | ||
jpbruinsslot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
|
||
all_queues_empty = False | ||
# TODO: check | ||
if response.count == 0: | ||
logger.debug("Queue %s empty", queue_type.value) | ||
time.sleep(10) | ||
return | ||
|
||
for p_item in response.results: | ||
logger.info("Handling task[%s]", p_item.data.id) | ||
|
||
try: | ||
|
@@ -134,12 +120,6 @@ def _fill_queue(self, task_queue: Queue, queue_type: WorkerManager.Queue) -> Non | |
except HTTPError: | ||
logger.exception("Could not patch scheduler task to %s", TaskStatus.FAILED.value) | ||
|
||
raise | ||
|
||
if all_queues_empty: | ||
logger.debug("All queues empty, sleeping %f seconds", self.settings.poll_interval) | ||
time.sleep(self.settings.poll_interval) | ||
|
||
def _check_workers(self) -> None: | ||
new_workers = [] | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.