Merge "vswitch optionality on worker node"

This commit is contained in:
Zuul 2019-04-15 19:56:48 +00:00 committed by Gerrit Code Review
commit 5e1cdcd909
3 changed files with 26 additions and 5 deletions

View File

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
#
# Copyright (c) 2013-2016 Wind River Systems, Inc.
# Copyright (c) 2013-2019 Wind River Systems, Inc.
#
@ -491,10 +491,7 @@ def _update_vswitch_cpu_counts(host, cpu, counts, capabilities=None):
first and that all other allocations will be dynamically adjusted based on
how many cores are remaining.
"""
labels = pecan.request.dbapi.label_get_by_host(host.uuid)
if not cutils.has_openstack_compute(labels):
raise wsme.exc.ClientSideError(_('vSwitch cpus can only be used with '
'openstack-compute nodes.'))
vswitch_type = cutils.get_vswitch_type(pecan.request.dbapi)
for s in range(0, len(host.nodes)):
if capabilities:
count = capabilities.get('num_cores_on_processor%d' % s, None)
@ -504,6 +501,10 @@ def _update_vswitch_cpu_counts(host, cpu, counts, capabilities=None):
if count is None:
continue
count = int(count)
if constants.VSWITCH_TYPE_NONE == vswitch_type and count != 0:
raise wsme.exc.ClientSideError(
_('vSwitch cpus can only be used with a vswitch_type '
'specified.'))
if count < 0:
raise wsme.exc.ClientSideError(_('vSwitch cpus must be non-negative.'))
if host.hyperthreading:

View File

@ -4220,6 +4220,21 @@ class HostController(rest.RestController):
"Please refer to system admin guide for more details.") %
(ihost['hostname']))
def _semantic_check_worker_cpu_assignments(self, host):
"""
Perform semantic checks that cpu assignments are valid. Changes in
vswitch_type may alter vswitch core requirements.
"""
# If vswitch_type is none, enforce 0 vswitch cpu cores
if constants.VSWITCH_TYPE_NONE == cutils.get_vswitch_type(
pecan.request.dbapi):
host_cpus = pecan.request.dbapi.icpu_get_by_ihost(host['uuid'])
for cpu in host_cpus:
if cpu.allocated_function == constants.VSWITCH_FUNCTION:
raise wsme.exc.ClientSideError(
_('vSwitch cpus can only be used with a vswitch_type '
'specified.'))
@staticmethod
def _handle_ttys_dcd_change(ihost, ttys_dcd):
"""
@ -5186,6 +5201,9 @@ class HostController(rest.RestController):
self._semantic_check_data_addresses(ihost)
self._semantic_check_data_vrs_attributes(ihost)
# Check if cpu assignments are valid
self._semantic_check_worker_cpu_assignments(ihost)
# check if the platform reserved memory is valid
ihost_inodes = pecan.request.dbapi.inode_get_by_ihost(ihost['uuid'])
mib_reserved = 0

View File

@ -2547,6 +2547,8 @@ class ConductorManager(service.PeriodicService):
cpu_count, hyperthreading):
"""Return the initial number of reserved logical cores for vswitch
use. This can be overridden later by the end user."""
if constants.VSWITCH_TYPE_NONE == cutils.get_vswitch_type(self.dbapi):
return 0
if cutils.host_has_function(ihost, constants.WORKER) and node == 0:
physical_cores = (cpu_count / 2) if hyperthreading else cpu_count
system_mode = self.dbapi.isystem_get_one().system_mode