Enable --reserved-cpus option in k8s v1.18.1
The option was introduced in k8s v1.17 and will now be used to define the explicit set of CPUs that are reserved for specific cpu functions in StarlingX. This retires setting the number of CPUs reserved in the --kube-reserved and --system-reserved options. Instead of calculating the number of CPUs related to reservations, provide the specific list of CPUs in a comma separated range format. This will be used by puppet to set the --reserved-cpus option based on cpu manager policy. Remove restrictions around CPU assignments: - Allow platform cores to be reserved on any processor - Allow application isolated cores to be reserved on any processor Change-Id: I1a3d4e4cca7b6940682a787c2e7348e56a047a06 Depends-On: https://review.opendev.org/#/c/722189 Story: 2006999 Task: 39528 Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
parent
0333ccbb42
commit
92828038b4
|
@ -281,11 +281,6 @@ def check_core_allocations(host, cpu_counts):
|
|||
elif total_platform_cores == 0:
|
||||
raise wsme.exc.ClientSideError("%s must have at least one core." %
|
||||
constants.PLATFORM_FUNCTION)
|
||||
for s in range(1, len(host.nodes)):
|
||||
if cpu_counts[s][constants.PLATFORM_FUNCTION] > 0:
|
||||
raise wsme.exc.ClientSideError(
|
||||
"%s cores can only be allocated on Processor 0" %
|
||||
constants.PLATFORM_FUNCTION)
|
||||
|
||||
# Validate shared cores
|
||||
for s in range(0, len(host.nodes)):
|
||||
|
@ -313,31 +308,15 @@ def check_core_allocations(host, cpu_counts):
|
|||
"The %s function can only be assigned up to %s cores." %
|
||||
(constants.VSWITCH_FUNCTION.lower(), VSWITCH_MAX_CORES))
|
||||
|
||||
# Validate Isolated cores
|
||||
# We can allocate platform cores on numa 0, otherwise all isolated
|
||||
# cores must in a contiguous block after the platform cores.
|
||||
# Validate Isolated cores:
|
||||
# - Prevent isolated core assignment if vswitch or shared cores are
|
||||
# allocated.
|
||||
if total_isolated_cores > 0:
|
||||
if total_vswitch_cores != 0 or total_shared_cores != 0:
|
||||
raise wsme.exc.ClientSideError(
|
||||
"%s cores can only be configured with %s and %s core types." %
|
||||
(constants.ISOLATED_FUNCTION, constants.PLATFORM_FUNCTION,
|
||||
constants.APPLICATION_FUNCTION))
|
||||
has_application_cpus = False
|
||||
for s in range(0, len(host.nodes)):
|
||||
numa_counts = cpu_counts[s]
|
||||
isolated_cores_requested = \
|
||||
numa_counts[constants.ISOLATED_FUNCTION]
|
||||
if has_application_cpus and isolated_cores_requested:
|
||||
raise wsme.exc.ClientSideError(
|
||||
"%s and %s cpus must be contiguous" %
|
||||
(constants.PLATFORM_FUNCTION, constants.ISOLATED_FUNCTION))
|
||||
platform_cores_requested = \
|
||||
numa_counts[constants.PLATFORM_FUNCTION]
|
||||
available_cores = len(host.cpu_lists[s])
|
||||
|
||||
if platform_cores_requested + isolated_cores_requested \
|
||||
!= available_cores:
|
||||
has_application_cpus = True
|
||||
|
||||
reserved_for_applications = len(host.cpus) - total_platform_cores - \
|
||||
total_vswitch_cores
|
||||
|
|
|
@ -269,10 +269,12 @@ class KubernetesPuppet(base.BasePuppet):
|
|||
host, function=constants.ISOLATED_FUNCTION, threads=True)
|
||||
isol_cpuset = set([c.cpu for c in isol_cpus])
|
||||
|
||||
# determine platform reserved number of logical cpus
|
||||
k8s_reserved_cpus = len(platform_cpuset)
|
||||
|
||||
k8s_isol_cpus = len(vswitch_cpuset) + len(isol_cpuset)
|
||||
# determine reserved sets of logical cpus in a string range set format
|
||||
# to pass as options to kubelet
|
||||
k8s_platform_cpuset = utils.format_range_set(platform_cpuset)
|
||||
k8s_all_reserved_cpuset = utils.format_range_set(platform_cpuset |
|
||||
vswitch_cpuset |
|
||||
isol_cpuset)
|
||||
|
||||
# determine platform reserved memory
|
||||
k8s_reserved_mem = 0
|
||||
|
@ -324,10 +326,10 @@ class KubernetesPuppet(base.BasePuppet):
|
|||
"\"%s\"" % k8s_cpuset,
|
||||
'platform::kubernetes::params::k8s_nodeset':
|
||||
"\"%s\"" % k8s_nodeset,
|
||||
'platform::kubernetes::params::k8s_reserved_cpus':
|
||||
k8s_reserved_cpus,
|
||||
'platform::kubernetes::params::k8s_isol_cpus':
|
||||
k8s_isol_cpus,
|
||||
'platform::kubernetes::params::k8s_platform_cpuset':
|
||||
k8s_platform_cpuset,
|
||||
'platform::kubernetes::params::k8s_all_reserved_cpuset':
|
||||
k8s_all_reserved_cpuset,
|
||||
'platform::kubernetes::params::k8s_reserved_mem':
|
||||
k8s_reserved_mem,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue