Migrate API service to use native threading

This commit performs the first service migration from eventlet to
standard python threading, focusing on the `designate-api` service.

The API service main entrypoint (designate/cmd/api.py) now explicitly
initializes oslo_service threading backend. It will be removed when
the migration is complete.

Change-Id: Ic15de389f01a42f8dc918511e9a60df1449f1bed
Signed-off-by: Omer <oschwart@redhat.com>
This commit is contained in:
Omer
2025-06-20 10:01:46 +00:00
parent 69e7e0d0f9
commit d99a5fc9d7
6 changed files with 20 additions and 9 deletions

View File

@@ -41,4 +41,7 @@ def main():
heartbeat = heartbeat_emitter.get_heartbeat_emitter(server.service_name)
service.serve(server, workers=CONF['service:api'].workers)
heartbeat.start()
service.wait()
try:
service.wait()
finally:
heartbeat.stop()

View File

@@ -23,8 +23,8 @@ API_GROUP = cfg.OptGroup(
API_OPTS = [
cfg.IntOpt('workers',
help='Number of api worker processes to spawn'),
cfg.IntOpt('threads', default=1000,
help='Number of api greenthreads to spawn'),
cfg.IntOpt('threads', default=100,
help='Number of api threads to spawn'),
cfg.BoolOpt('enable_host_header', default=True,
help='Enable host request headers'),
cfg.StrOpt('api_base_uri', default='http://127.0.0.1:9001/',

View File

@@ -13,7 +13,7 @@
# 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 eventlet.patcher
from dns import reversename
from oslo_log import log as logging
import designate.conf
@@ -23,9 +23,6 @@ from designate.plugin import DriverPlugin
CONF = designate.conf.CONF
LOG = logging.getLogger(__name__)
# NOTE(kiall): This is a workaround for bug #1424621, a broken reimplementation
# of eventlet's 0.17.0 monkey patching of dnspython.
reversename = eventlet.patcher.original('dns.reversename')
class NetworkAPI(DriverPlugin):

View File

@@ -14,7 +14,6 @@ from unittest import mock
from oslo_config import fixture as cfg_fixture
import oslotest.base
from designate.cmd.eventlet import api
from designate.cmd.eventlet import central
from designate.cmd.eventlet import mdns
from designate.cmd.eventlet import producer
@@ -26,6 +25,10 @@ import designate.conf
CONF = designate.conf.CONF
with mock.patch('oslo_service.backend.init_backend'):
from designate.cmd.threading import api
@mock.patch('designate.service.wait')
@mock.patch('designate.service.serve')
@mock.patch('designate.heartbeat_emitter.get_heartbeat_emitter')

View File

@@ -0,0 +1,8 @@
---
upgrade:
- |
The designate-api service has been migrated from eventlet to use
native Python threading.
The default number of API threads has been reduced from 1000 to 100
to reflect the change from eventlet greenthreads to native OS threads.

View File

@@ -53,7 +53,7 @@ oslo.policy.enforcer =
console_scripts =
designate-rootwrap = oslo_rootwrap.cmd:main
designate-api = designate.cmd.eventlet.api:main
designate-api = designate.cmd.threading.api:main
designate-central = designate.cmd.eventlet.central:main
designate-manage = designate.cmd.eventlet.manage:main
designate-mdns = designate.cmd.eventlet.mdns:main