Add 'enable_cpu_pinning' to compute_node

Change-Id: I7255296c785ae4780e589d0489dc26cfedd9b9e4
Implements: blueprint cpuset-container
This commit is contained in:
Hongbin Lu 2018-12-12 03:43:03 +00:00
parent dcd7cf35d4
commit 6d880e6f15
15 changed files with 66 additions and 7 deletions

View File

@ -45,6 +45,7 @@ Response Parameters
- os_type: host-os_type
- total_containers: host-total_containers
- uuid: host-uuid
- enable_cpu_pinning: enable_cpu_pinning
Response Example
----------------
@ -98,6 +99,7 @@ Response
- os_type: host-os_type
- total_containers: host-total_containers
- uuid: host-uuid
- enable_cpu_pinning: enable_cpu_pinning
Response Example
----------------

View File

@ -442,6 +442,12 @@ disk-response:
required: true
in: body
type: object
enable_cpu_pinning:
description: |
Indicate whether this host has cpu pinning enabled.
in: body
required: true
type: object
environment:
description: |
The environment variables.

View File

@ -33,6 +33,7 @@ _basic_keys = (
'disk_total',
'disk_quota_supported',
'runtimes',
'enable_cpu_pinning',
)

View File

@ -61,10 +61,11 @@ REST_API_VERSION_HISTORY = """REST API Version History:
* 1.26 - Introduce Quota support
* 1.27 - Add support for deleting networks
* 1.28 - Add support cpuset
* 1.29 - Add enable_cpu_pinning to compute_node
"""
BASE_VER = '1.1'
CURRENT_MAX_VER = '1.28'
CURRENT_MAX_VER = '1.29'
class Version(object):

View File

@ -225,3 +225,8 @@ user documentation.
Add a new attribute 'cpu_policy'.
Users can use this attribute to determine which CPU policy the container uses.
1.29
----
Add a new attribute 'enable_cpu_pinning' to 'host' resource.

View File

@ -1121,6 +1121,7 @@ class DockerDriver(driver.ContainerDriver):
else:
runtimes = ['runc']
docker_root_dir = info['DockerRootDir']
enable_cpu_pinning = CONF.compute.enable_cpu_pinning
return {'total_containers': total,
'running_containers': running,
@ -1133,7 +1134,8 @@ class DockerDriver(driver.ContainerDriver):
'kernel_version': kernel_version,
'labels': labels,
'runtimes': runtimes,
'docker_root_dir': docker_root_dir}
'docker_root_dir': docker_root_dir,
'enable_cpu_pinning': enable_cpu_pinning}
def get_total_disk_for_container(self):
try:

View File

@ -250,6 +250,7 @@ class ContainerDriver(object):
disk_quota_supported = self.node_support_disk_quota()
node.disk_quota_supported = disk_quota_supported
node.runtimes = info['runtimes']
node.enable_cpu_pinning = info['enable_cpu_pinning']
def node_is_available(self, nodename):
"""Return whether this compute service manages a particular node."""

View File

@ -0,0 +1,35 @@
# 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.
"""add enable_cpu_pinning to compute_node
Revision ID: 21fa080c818a
Revises: 2b129060baff
Create Date: 2018-12-12 03:09:40.316168
"""
# revision identifiers, used by Alembic.
revision = '21fa080c818a'
down_revision = '2b129060baff'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('compute_node',
sa.Column('enable_cpu_pinning', sa.Boolean(),
nullable=False, default=sa.sql.false(),
server_default=sa.sql.false()))

View File

@ -385,6 +385,8 @@ class ComputeNode(Base):
disk_quota_supported = Column(Boolean, nullable=False, default=sql.false(),
server_default=sql.false())
runtimes = Column(JSONEncodedList, nullable=True)
enable_cpu_pinning = Column(Boolean, nullable=False, default=sql.false(),
server_default=sql.false())
class Capsule(Base):

View File

@ -34,7 +34,8 @@ class ComputeNode(base.ZunPersistentObject, base.ZunObject):
# Version 1.10: Add disk_total, disk_used columns
# Version 1.11: Add disk_quota_supported field
# Version 1.12: Add runtimes field
VERSION = '1.12'
# Version 1.13: Add enable_cpu_pinning field
VERSION = '1.13'
fields = {
'uuid': fields.UUIDField(read_only=True, nullable=False),
@ -63,6 +64,7 @@ class ComputeNode(base.ZunPersistentObject, base.ZunObject):
'disk_used': fields.IntegerField(nullable=False),
'disk_quota_supported': fields.BooleanField(nullable=False),
'runtimes': fields.ListOfStringsField(nullable=True),
'enable_cpu_pinning': fields.BooleanField(nullable=False),
}
@staticmethod

View File

@ -26,7 +26,7 @@ from zun.tests.unit.db import base
PATH_PREFIX = '/v1'
CURRENT_VERSION = "container 1.27"
CURRENT_VERSION = "container 1.29"
class FunctionalTest(base.DbTestCase):

View File

@ -28,7 +28,7 @@ class TestRootController(api_base.FunctionalTest):
'default_version':
{'id': 'v1',
'links': [{'href': 'http://localhost/v1/', 'rel': 'self'}],
'max_version': '1.28',
'max_version': '1.29',
'min_version': '1.1',
'status': 'CURRENT'},
'description': 'Zun is an OpenStack project which '
@ -37,7 +37,7 @@ class TestRootController(api_base.FunctionalTest):
'versions': [{'id': 'v1',
'links': [{'href': 'http://localhost/v1/',
'rel': 'self'}],
'max_version': '1.28',
'max_version': '1.29',
'min_version': '1.1',
'status': 'CURRENT'}]}

View File

@ -1026,6 +1026,7 @@ class TestDockerDriver(base.DriverTestCase):
'kernel_version': '3.10.0-123',
'labels': {'dev.type': 'product'},
'runtimes': ['runc'],
'enable_cpu_pinning': False,
'docker_root_dir': '/var/lib/docker'}
mock_cpu_used.return_value = 1.0
mock_disk.return_value = 80

View File

@ -408,6 +408,7 @@ def get_test_compute_node(**kwargs):
'disk_used': kwargs.get('disk_used', 20),
'disk_quota_supported': kwargs.get('disk_quota_supported', False),
'runtimes': kwargs.get('runtimes', ['runc']),
'enable_cpu_pinning': kwargs.get('enable_cpu_pinning', False),
}

View File

@ -357,7 +357,7 @@ object_data = {
'ZunService': '1.2-deff2a74a9ce23baa231ae12f39a6189',
'Capsule': '1.7-4b895382ee5c44742a9fdc6be85437c7',
'PciDevice': '1.1-6e3f0851ad1cf12583e6af4df1883979',
'ComputeNode': '1.12-12d7c4fdeb26d58e1988d8577c838512',
'ComputeNode': '1.13-3c122f455c38d3665d327c05d2df6617',
'PciDevicePool': '1.0-3f5ddc3ff7bfa14da7f6c7e9904cc000',
'PciDevicePoolList': '1.0-15ecf022a68ddbb8c2a6739cfc9f8f5e',
'Quota': '1.2-3a7d520d119fe1e886baad968ef7990a',