summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindep.txt2
-rw-r--r--ironic/common/wsgi_service.py11
-rw-r--r--ironic/conf/api.py6
-rw-r--r--ironic/drivers/modules/image_utils.py3
-rw-r--r--ironic/tests/unit/common/test_wsgi_service.py14
-rw-r--r--releasenotes/notes/api-workers-c06ea95a0c55b8cf.yaml9
-rw-r--r--releasenotes/notes/fix-network-data2-f2600afdcc182dc4.yaml4
-rwxr-xr-xtools/test-setup.sh23
8 files changed, 61 insertions, 11 deletions
diff --git a/bindep.txt b/bindep.txt
index 36b4ce35d..d2e63ea2b 100644
--- a/bindep.txt
+++ b/bindep.txt
@@ -47,12 +47,12 @@ net-tools [platform:rpm devstack]
# these are needed to compile Python dependencies from sources
python-dev [platform:dpkg test]
python3-all-dev [platform:dpkg !platform:ubuntu-precise test]
-python-devel [platform:rpm test]
python3-devel [platform:rpm test]
build-essential [platform:dpkg test]
libssl-dev [platform:dpkg test]
# these are needed by infra for python-* jobs
libpq-dev [platform:dpkg test]
+libpq-devel [platform:rpm test]
postgresql
postgresql-client [platform:dpkg]
# postgresql-devel [platform:rpm]
diff --git a/ironic/common/wsgi_service.py b/ironic/common/wsgi_service.py
index 5c30d708e..e7bbe9dcd 100644
--- a/ironic/common/wsgi_service.py
+++ b/ironic/common/wsgi_service.py
@@ -20,6 +20,9 @@ from ironic.common.i18n import _
from ironic.conf import CONF
+_MAX_DEFAULT_WORKERS = 4
+
+
class WSGIService(service.ServiceBase):
"""Provides ability to launch ironic API from wsgi app."""
@@ -32,8 +35,12 @@ class WSGIService(service.ServiceBase):
"""
self.name = name
self.app = app.VersionSelectorApplication()
- self.workers = (CONF.api.api_workers
- or processutils.get_worker_count())
+ self.workers = (
+ CONF.api.api_workers
+ # NOTE(dtantsur): each worker takes a substantial amount of memory,
+ # so we don't want to end up with dozens of them.
+ or min(processutils.get_worker_count(), _MAX_DEFAULT_WORKERS)
+ )
if self.workers and self.workers < 1:
raise exception.ConfigInvalid(
_("api_workers value of %d is invalid, "
diff --git a/ironic/conf/api.py b/ironic/conf/api.py
index 80a30acfc..ba23627b0 100644
--- a/ironic/conf/api.py
+++ b/ironic/conf/api.py
@@ -44,9 +44,9 @@ opts = [
),
cfg.IntOpt('api_workers',
help=_('Number of workers for OpenStack Ironic API service. '
- 'The default is equal to the number of CPUs available '
- 'if that can be determined, else a default worker '
- 'count of 1 is returned.')),
+ 'The default is equal to the number of CPUs available, '
+ 'but not more than 4. One worker is used if the CPU '
+ 'number cannot be detected.')),
cfg.BoolOpt('enable_ssl_api',
default=False,
help=_("Enable the integrated stand-alone API to service "
diff --git a/ironic/drivers/modules/image_utils.py b/ironic/drivers/modules/image_utils.py
index 40ae866fe..dcdeff9d1 100644
--- a/ironic/drivers/modules/image_utils.py
+++ b/ironic/drivers/modules/image_utils.py
@@ -468,8 +468,7 @@ def prepare_deploy_iso(task, params, mode, d_info):
json.dump(network_data, f, indent=2)
files_info = {
- metadata_fileobj.name: 'openstack/latest/meta'
- 'data/network_data.json'
+ metadata_fileobj.name: 'openstack/latest/network_data.json'
}
with tempfile.NamedTemporaryFile(
diff --git a/ironic/tests/unit/common/test_wsgi_service.py b/ironic/tests/unit/common/test_wsgi_service.py
index 5af26bf37..bc63c0dd2 100644
--- a/ironic/tests/unit/common/test_wsgi_service.py
+++ b/ironic/tests/unit/common/test_wsgi_service.py
@@ -23,12 +23,12 @@ CONF = cfg.CONF
class TestWSGIService(base.TestCase):
+ @mock.patch.object(processutils, 'get_worker_count', lambda: 2)
@mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True)
def test_workers_set_default(self, mock_server):
service_name = "ironic_api"
test_service = wsgi_service.WSGIService(service_name)
- self.assertEqual(processutils.get_worker_count(),
- test_service.workers)
+ self.assertEqual(2, test_service.workers)
mock_server.assert_called_once_with(CONF, service_name,
test_service.app,
host='0.0.0.0',
@@ -41,11 +41,19 @@ class TestWSGIService(base.TestCase):
test_service = wsgi_service.WSGIService("ironic_api")
self.assertEqual(8, test_service.workers)
+ @mock.patch.object(processutils, 'get_worker_count', lambda: 3)
@mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True)
def test_workers_set_zero_setting(self, mock_server):
self.config(api_workers=0, group='api')
test_service = wsgi_service.WSGIService("ironic_api")
- self.assertEqual(processutils.get_worker_count(), test_service.workers)
+ self.assertEqual(3, test_service.workers)
+
+ @mock.patch.object(processutils, 'get_worker_count', lambda: 42)
+ @mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True)
+ def test_workers_set_default_limit(self, mock_server):
+ self.config(api_workers=0, group='api')
+ test_service = wsgi_service.WSGIService("ironic_api")
+ self.assertEqual(4, test_service.workers)
@mock.patch.object(wsgi_service.wsgi, 'Server', autospec=True)
def test_workers_set_negative_setting(self, mock_server):
diff --git a/releasenotes/notes/api-workers-c06ea95a0c55b8cf.yaml b/releasenotes/notes/api-workers-c06ea95a0c55b8cf.yaml
new file mode 100644
index 000000000..075b8e2a4
--- /dev/null
+++ b/releasenotes/notes/api-workers-c06ea95a0c55b8cf.yaml
@@ -0,0 +1,9 @@
+---
+upgrade:
+ - |
+ The default value of ``[api]api_workers`` is now limited to 4. Set it
+ explicitly if you need a higher value.
+fixes:
+ - |
+ No longer launches too many API workers on systems with a lot of CPU
+ cores by default.
diff --git a/releasenotes/notes/fix-network-data2-f2600afdcc182dc4.yaml b/releasenotes/notes/fix-network-data2-f2600afdcc182dc4.yaml
new file mode 100644
index 000000000..501abd108
--- /dev/null
+++ b/releasenotes/notes/fix-network-data2-f2600afdcc182dc4.yaml
@@ -0,0 +1,4 @@
+---
+fixes:
+ - |
+ Fixes incorrect injected network data location when using virtual media.
diff --git a/tools/test-setup.sh b/tools/test-setup.sh
index c82f4716a..dc2a130b9 100755
--- a/tools/test-setup.sh
+++ b/tools/test-setup.sh
@@ -4,6 +4,12 @@
# it sets up the test system as needed.
# Developers should setup their test systems in a similar way.
+# Try starting mariadb
+sudo systemctl start mariadb || true
+# Try starting postgresql
+sudo postgresql-setup --initdb || true
+sudo systemctl start postgresql || true
+
# This setup needs to be run as a user that can run sudo.
# The root password for the MySQL database; pass it in via
@@ -37,6 +43,14 @@ mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e "
# POSTGRES_ROOT_PW.
DB_ROOT_PW=${POSTGRES_ROOT_PW:-insecure_slave}
+# Change working directory to a folder all users can access
+# as psql on centos8 needs to be able to open the working directory
+# which it can't when executed as the postgres user, which is required
+# as same user as process for initial administrative authentication to
+# the postgres database
+
+cd /tmp
+
# Setup user
root_roles=$(sudo -H -u postgres psql -t -c "
SELECT 'HERE' from pg_roles where rolname='$DB_USER'")
@@ -46,6 +60,15 @@ else
sudo -H -u postgres psql -c "CREATE ROLE $DB_USER WITH SUPERUSER LOGIN PASSWORD '$DB_PW'"
fi
+# Identify and update the postgres hba file which can be in
+# a version specific path.
+PG_HBA=$(sudo -H -u postgres psql -t -c "show hba_file")
+sudo sed -i 's/ident/trust/g' $PG_HBA
+sudo cat $PG_HBA
+# restart postgres fo new HBA file is loaded and our user trusted.
+sudo systemctl stop postgresql || true
+sudo systemctl start postgresql || true
+
# Store password for tests
cat << EOF > $HOME/.pgpass
*:*:*:$DB_USER:$DB_PW