diff --git a/setup.cfg b/setup.cfg index c3ee76534..a26f7d012 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,10 +39,10 @@ oslo.policy.enforcer = watcher = watcher.common.policy:get_enforcer console_scripts = - watcher-api = watcher.cmd.api:main + watcher-api = watcher.cmd.eventlet.api:main watcher-db-manage = watcher.cmd.dbmanage:main - watcher-decision-engine = watcher.cmd.decisionengine:main - watcher-applier = watcher.cmd.applier:main + watcher-decision-engine = watcher.cmd.eventlet.decisionengine:main + watcher-applier = watcher.cmd.eventlet.applier:main watcher-sync = watcher.cmd.sync:main watcher-status = watcher.cmd.status:main diff --git a/watcher/cmd/__init__.py b/watcher/cmd/__init__.py index fe21c7a40..e69de29bb 100644 --- a/watcher/cmd/__init__.py +++ b/watcher/cmd/__init__.py @@ -1,29 +0,0 @@ -# -# 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. - -# NOTE(licanwei): Do eventlet monkey patching here, instead of in -# common/service.py. This allows the API service to run without monkey -# patching under Apache (which uses its own concurrency model). Mixing -# concurrency models can cause undefined behavior and potentially API timeouts. -# NOTE(sean-k-mooney) while ^ is true, since that was written asyncio was added -# to the code base in addition to apscheduler which provides native threads. -# As such we have a lot of technical debt to fix with regards to watchers -# concurrency model as we are mixing up to 3 models the same process. -# apscheduler does not technically support eventlet but it has mostly worked -# until now, apscheduler is used to provide a job schedulers which mixes -# monkey patched and non monkey patched code in the same process. -# That is problematic and can lead to errors on python 3.12+. -# The maas support added asyncio to the codebase which is unsafe to mix -# with eventlets by default. -from watcher import eventlet -eventlet.patch() diff --git a/watcher/cmd/eventlet/__init__.py b/watcher/cmd/eventlet/__init__.py new file mode 100644 index 000000000..fe21c7a40 --- /dev/null +++ b/watcher/cmd/eventlet/__init__.py @@ -0,0 +1,29 @@ +# +# 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. + +# NOTE(licanwei): Do eventlet monkey patching here, instead of in +# common/service.py. This allows the API service to run without monkey +# patching under Apache (which uses its own concurrency model). Mixing +# concurrency models can cause undefined behavior and potentially API timeouts. +# NOTE(sean-k-mooney) while ^ is true, since that was written asyncio was added +# to the code base in addition to apscheduler which provides native threads. +# As such we have a lot of technical debt to fix with regards to watchers +# concurrency model as we are mixing up to 3 models the same process. +# apscheduler does not technically support eventlet but it has mostly worked +# until now, apscheduler is used to provide a job schedulers which mixes +# monkey patched and non monkey patched code in the same process. +# That is problematic and can lead to errors on python 3.12+. +# The maas support added asyncio to the codebase which is unsafe to mix +# with eventlets by default. +from watcher import eventlet +eventlet.patch() diff --git a/watcher/cmd/api.py b/watcher/cmd/eventlet/api.py similarity index 100% rename from watcher/cmd/api.py rename to watcher/cmd/eventlet/api.py diff --git a/watcher/cmd/applier.py b/watcher/cmd/eventlet/applier.py similarity index 100% rename from watcher/cmd/applier.py rename to watcher/cmd/eventlet/applier.py diff --git a/watcher/cmd/decisionengine.py b/watcher/cmd/eventlet/decisionengine.py similarity index 100% rename from watcher/cmd/decisionengine.py rename to watcher/cmd/eventlet/decisionengine.py diff --git a/watcher/tests/cmd/test_api.py b/watcher/tests/cmd/test_api.py index 2d57c9cb4..7e2b50fae 100644 --- a/watcher/tests/cmd/test_api.py +++ b/watcher/tests/cmd/test_api.py @@ -22,7 +22,7 @@ from oslo_service import wsgi from pecan.testing import load_test_app from watcher.api import config as api_config -from watcher.cmd import api +from watcher.cmd.eventlet import api from watcher.common import service from watcher.tests import base diff --git a/watcher/tests/cmd/test_applier.py b/watcher/tests/cmd/test_applier.py index c865b4a57..e382d7ce4 100644 --- a/watcher/tests/cmd/test_applier.py +++ b/watcher/tests/cmd/test_applier.py @@ -21,7 +21,7 @@ from oslo_config import cfg from oslo_service import service from watcher.applier import sync -from watcher.cmd import applier +from watcher.cmd.eventlet import applier from watcher.common import service as watcher_service from watcher.tests import base diff --git a/watcher/tests/cmd/test_decision_engine.py b/watcher/tests/cmd/test_decision_engine.py index 81ac6f2c7..66ab0b7cb 100644 --- a/watcher/tests/cmd/test_decision_engine.py +++ b/watcher/tests/cmd/test_decision_engine.py @@ -20,7 +20,7 @@ from unittest import mock from oslo_config import cfg from oslo_service import service -from watcher.cmd import decisionengine +from watcher.cmd.eventlet import decisionengine from watcher.common import service as watcher_service from watcher.decision_engine.audit import continuous from watcher.decision_engine import sync