-
Notifications
You must be signed in to change notification settings - Fork 49
Enable dispatcherd under feature flag 1st iteration - AAP-46009 #1308
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
Open
Alex-Izquierdo
wants to merge
29
commits into
main
Choose a base branch
from
enable-dispatcherd-1st-iteration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
af14e40
wip: added dependency and initial conf (#1281)
Alex-Izquierdo ba958a2
wip: fix initial conf (#1282)
Alex-Izquierdo 4c74f3c
wip: move worker settings to settings file (#1285)
Alex-Izquierdo 94411c3
wip: upd poetry, add dispatcher to analitics and orchestrator (#1286)
Alex-Izquierdo 99a5a8e
wip: initial implemention finished, pending of real tests (#1288)
Alex-Izquierdo b1cd6bb
wip projects, moved hazmat (#1289)
Alex-Izquierdo 36f54a6
wip: project import fixed, pending project sync. DAB upgraded (#1290)
Alex-Izquierdo 14f9648
wip: cache and simplify getting feature flag (#1291)
bzwei fb6b14e
chore: rebase from main, solving conflicts with new feature flags
Alex-Izquierdo 69b0003
wip: upgrade dispatcher, projects and activations working. (#1296)
Alex-Izquierdo 73f2b88
rebase from main
Alex-Izquierdo e39469c
fix: test_orchestrator (#1303)
bzwei 22f2332
fix test_tasking (#1302)
bzwei bc90e58
fix: wsapi test_consumer (#1301)
bzwei ebf3277
Fix integration tests (#1300)
bzwei 41246e7
test: fix job uniqueness test (#1299)
Alex-Izquierdo a72e7b9
rebase from main
Alex-Izquierdo 11ceefc
ci: fix isort (#1305)
Alex-Izquierdo 40d7956
test: fix test_manager tests (#1304)
Alex-Izquierdo e82c7cf
fix: test_orchestrator (#1309)
bzwei b1e2309
fix: linting (#1310)
bzwei a29e480
chore: remove metrics extra and rename hazmat (#1312)
Alex-Izquierdo 887e5d9
rebase from main
Alex-Izquierdo 076e35e
chore: followup hazmat renaming, missing ref (#1313)
Alex-Izquierdo 9e7caee
fix command wrapper tests (#1314)
Alex-Izquierdo d5ab1ea
remove unnecessary decorator for rq analytics (#1317)
Alex-Izquierdo accfe71
rebase from main
Alex-Izquierdo ba58e7c
upgrade dispatcherd and poetry
Alex-Izquierdo be870c4
rebase from main
Alex-Izquierdo 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2025 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import django | ||
from django.core.cache import cache | ||
from django.db import connection | ||
|
||
"""This module is an optimization for dispatcherd workers | ||
|
||
This sets up Django pre-fork, which must be implemented as a module to run | ||
on-import for compatibility with multiprocessing forkserver. | ||
This should never be imported by other modules, which is why it is called | ||
hazmat. | ||
""" | ||
|
||
|
||
django.setup() | ||
|
||
# connections may or may not be open, but | ||
# before forking, all connections should be closed | ||
|
||
cache.close() | ||
connection.close() |
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 |
---|---|---|
|
@@ -14,12 +14,18 @@ | |
|
||
"""Wrapper for rqworker command.""" | ||
|
||
import logging | ||
|
||
from dispatcherd import run_service as run_dispatcherd_service | ||
from dispatcherd.config import setup as dispatcherd_setup | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand, CommandParser | ||
from django_rq.management.commands import rqworker | ||
|
||
from aap_eda.settings import features | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Wrapper for rqworker command. | ||
|
@@ -35,12 +41,29 @@ def add_arguments(self, parser: CommandParser) -> None: | |
|
||
def handle(self, *args, **options) -> None: | ||
if features.DISPATCHERD: | ||
self.stderr.write( | ||
if "worker_class" not in options: | ||
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. @Alex-Izquierdo Can this code block be moved into something like handle_dispatcherd |
||
self.style.ERROR("Missing required argument: --worker-class") | ||
raise SystemExit(1) | ||
|
||
# Use rqworker expected args to determine worker type | ||
if "ActivationWorker" in options["worker_class"]: | ||
dispatcherd_setup( | ||
settings.DISPATCHERD_ACTIVATION_WORKER_SETTINGS, | ||
) | ||
|
||
elif "DefaultWorker" in options["worker_class"]: | ||
dispatcherd_setup(settings.DISPATCHERD_DEFAULT_WORKER_SETTINGS) | ||
else: | ||
self.style.ERROR( | ||
"DISPATCHERD feature not implemented yet. " | ||
f"Please disable {settings.DISPATCHERD_FEATURE_FLAG_NAME} " | ||
"in your settings.", | ||
"Invalid worker class. " | ||
"Please use either ActivationWorker or DefaultWorker." | ||
) | ||
) | ||
raise SystemExit(1) | ||
raise SystemExit(1) | ||
|
||
logger.info("Starting worker with dispatcherd.") | ||
run_dispatcherd_service() | ||
return None | ||
|
||
# run rqworker command if dispatcherd is not enabled | ||
logger.info("Starting worker with rqworker.") | ||
return rqworker.Command.handle(self, *args, **options) |
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.