Merge "Manager code to set CLI_CONFIRMATIONS in env"

This commit is contained in:
Zuul 2025-04-14 15:21:23 +00:00 committed by Gerrit Code Review
commit 7e8ad8a959
5 changed files with 137 additions and 13 deletions

View File

@ -658,7 +658,7 @@ class ServiceParameterController(rest.RestController):
try:
# Pass name to update_service_config only in case the parameters are the Intel
# NIC driver version, intel_pstate or sysinv_api_workers.
# NIC driver version, intel_pstate or sysinv_api_workers, cli_confirmations
new_name = None
if section == constants.SERVICE_PARAM_SECTION_PLATFORM_CONFIG and \
name == constants.SERVICE_PARAM_NAME_PLAT_CONFIG_INTEL_PSTATE:
@ -668,6 +668,10 @@ class ServiceParameterController(rest.RestController):
name == constants.SERVICE_PARAM_NAME_PLATFORM_SYSINV_API_WORKERS:
new_name = name
if section == constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT \
and name == constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
new_name = name
# TODO (kdhokte): Remove this and change the code in sysinv conductor
# to mark all parameters of sections kube-scheduler and kube-controller-manager
# as non-reboot-required.
@ -825,6 +829,7 @@ class ServiceParameterController(rest.RestController):
# Pass name to update_service_config only in case the parameter is
# the Intel NIC driver version, intel_pstate or sysinv_api_workers
# or cli_confirmations
name = None
if parameter.section == constants.SERVICE_PARAM_SECTION_PLATFORM_CONFIG and \
parameter.name == constants.SERVICE_PARAM_NAME_PLAT_CONFIG_INTEL_PSTATE:
@ -834,6 +839,10 @@ class ServiceParameterController(rest.RestController):
parameter.name == constants.SERVICE_PARAM_NAME_PLATFORM_SYSINV_API_WORKERS:
name = parameter.name
if parameter.section == constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT \
and parameter.name == constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
name = parameter.name
# TODO bqian: remove this if branch for stx-11
if parameter.section == constants.SERVICE_PARAM_SECTION_KUBERNETES_CONTROLLER_MANAGER and \
parameter.name == "pod-eviction-timeout":

View File

@ -1491,6 +1491,7 @@ SERVICE_PARAM_SECTION_DNS_HOST_RECORD = 'host-record'
SERVICE_PARAM_NAME_DNS_HOST_RECORD_HOSTS = 'hosts'
# cli-confirmation parameters
SERVICE_PARAM_SECTION_PLATFORM_CLIENT = 'client'
SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS = 'cli_confirmations'
SERVICE_PARAM_DISABLED = 'disabled'
SERVICE_PARAM_ENABLED = 'enabled'

View File

@ -863,8 +863,7 @@ PLATFORM_CONFIG_PARAMETER_OPTIONAL = [
constants.SERVICE_PARAM_NAME_PLATFORM_MAX_CPU_PERCENTAGE,
constants.SERVICE_PARAM_NAME_PLAT_CONFIG_INTEL_PSTATE,
constants.SERVICE_PARAM_NAME_PLATFORM_SYSINV_API_WORKERS,
constants.SERVICE_PARAM_NAME_PLATFORM_SCTP_AUTOLOAD,
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS
constants.SERVICE_PARAM_NAME_PLATFORM_SCTP_AUTOLOAD
]
PLATFORM_CONFIG_PARAMETER_READONLY = [
@ -882,8 +881,6 @@ PLATFORM_CONFIG_PARAMETER_VALIDATOR = {
_validate_sysinv_api_workers,
constants.SERVICE_PARAM_NAME_PLATFORM_SCTP_AUTOLOAD:
_validate_sctp_autoload,
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
_validate_cli_confirmations,
}
PLATFORM_CONFIG_PARAMETER_RESOURCE = {
@ -895,8 +892,6 @@ PLATFORM_CONFIG_PARAMETER_RESOURCE = {
'platform::sysinv::params::sysinv_api_workers',
constants.SERVICE_PARAM_NAME_PLATFORM_SCTP_AUTOLOAD:
'platform::params::sctp_autoload',
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
'platform::params::cli_confirmations',
}
IDENTITY_LDAP_PARAMETER_OPTIONAL = [
@ -1566,6 +1561,20 @@ DNS_HOST_RECORD_PARAMETER_DATA_FORMAT = {
constants.SERVICE_PARAM_NAME_DNS_HOST_RECORD_HOSTS: SERVICE_PARAMETER_DATA_FORMAT_ARRAY,
}
PLATFORM_CLIENT_PARAMETER_OPTIONAL = [
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS
]
PLATFORM_CLIENT_PARAMETER_VALIDATOR = {
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
_validate_cli_confirmations,
}
PLATFORM_CLIENT_PARAMETER_RESOURCE = {
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
'platform::params::cli_confirmations',
}
# Service Parameter Schema
SERVICE_PARAM_MANDATORY = 'mandatory'
SERVICE_PARAM_OPTIONAL = 'optional'
@ -1663,6 +1672,11 @@ SERVICE_PARAMETER_SCHEMA = {
SERVICE_PARAM_VALIDATOR: PLATFORM_DRBD_PARAMETER_VALIDATOR,
SERVICE_PARAM_RESOURCE: PLATFORM_DRBD_PARAMETER_RESOURCE,
},
constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT: {
SERVICE_PARAM_OPTIONAL: PLATFORM_CLIENT_PARAMETER_OPTIONAL,
SERVICE_PARAM_VALIDATOR: PLATFORM_CLIENT_PARAMETER_VALIDATOR,
SERVICE_PARAM_RESOURCE: PLATFORM_CLIENT_PARAMETER_RESOURCE,
},
},
constants.SERVICE_TYPE_RADOSGW: {
constants.SERVICE_PARAM_SECTION_RADOSGW_CONFIG: {

View File

@ -902,7 +902,7 @@ class ConductorManager(service.PeriodicService):
'value': constants.SERVICE_PARAM_PLATFORM_SCTP_AUTOLOAD_ENABLED,
},
{'service': constants.SERVICE_TYPE_PLATFORM,
'section': constants.SERVICE_PARAM_SECTION_PLATFORM_CONFIG,
'section': constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT,
'name': constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS,
'value': constants.SERVICE_PARAM_DISABLED,
},
@ -12575,11 +12575,19 @@ class ConductorManager(service.PeriodicService):
}
self._config_apply_runtime_manifest(context, config_uuid, config_dict)
elif section == constants.SERVICE_PARAM_SECTION_PLATFORM_CONFIG and \
elif section == constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT and \
name == constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS:
# Do nothing. Does not need to update target config of any hosts
personalities = None
personalities = [constants.CONTROLLER,
constants.WORKER,
constants.STORAGE]
reboot = False
config_uuid = self._config_update_hosts(context, personalities, reboot=reboot)
config_dict = {
'personalities': personalities,
"classes": ['platform::client::cliconfirmations::runtime']
}
self._config_apply_runtime_manifest(context, config_uuid,
config_dict)
elif service == constants.SERVICE_TYPE_IDENTITY:
remote_ldap_domains = [constants.SERVICE_PARAM_SECTION_IDENTITY_LDAP_DOMAIN1,

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Wind River Systems, Inc.
# Copyright (c) 2019-2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -560,7 +560,6 @@ class ApiServiceParameterTestCaseMixin(object):
)
},
]
service_parameter_wildcard = {
'service': constants.SERVICE_TYPE_PTP,
'section': constants.SERVICE_PARAM_SECTION_PTP_GLOBAL,
@ -669,6 +668,87 @@ class ApiServiceParameterTestCaseMixin(object):
return formatted_data
class CLIConfirmationTestHelper(object):
def __init__(self, test_case):
self.test_case = test_case
self.invalid_msg = (
"Parameter '%s' value must be either '%s' or '%s'" %
(
constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS,
constants.SERVICE_PARAM_DISABLED,
constants.SERVICE_PARAM_ENABLED
)
)
self.cli_confirmations_service_param_test_cases = {
"valid_enabled": {
"value": "enabled",
"expect_error": False
},
"invalid_yes": {
"value": "yes",
"expect_error": True,
"error_message": self.invalid_msg
},
"invalid_capital_enabled": {
"value": "ENABLED",
"expect_error": True,
"error_message": self.invalid_msg
},
"invalid_numeric": {
"value": "123",
"expect_error": True,
"error_message": self.invalid_msg
}
}
self.cli_confirmation_base_object = {
'service': constants.SERVICE_TYPE_PLATFORM,
'section': constants.SERVICE_PARAM_SECTION_PLATFORM_CLIENT,
'name': constants.SERVICE_PARAM_NAME_PLATFORM_CLI_CONFIRMATIONS,
}
def _create_cli_confirmation_object(self, value="enabled"):
obj = dict(self.cli_confirmation_base_object)
obj["value"] = value
return self.test_case._create_db_object(obj)
def validate_post(self):
sorted_cases = sorted(
self.cli_confirmations_service_param_test_cases.items(),
key=lambda item: not item[1]["expect_error"]
)
for name, case in sorted_cases:
post_object = dict(self.cli_confirmation_base_object)
post_object['value'] = case["value"]
if case["expect_error"]:
self.test_case.post(post_object, expect_errors=True,
error_message=case["error_message"])
else:
self.test_case.post(post_object, expect_errors=False)
def validate_delete(self):
del_obj = self._create_cli_confirmation_object("enabled")
uuid = del_obj.uuid
response = self.test_case.delete(self.test_case.get_single_url(uuid),
headers=self.test_case.API_HEADERS)
self.test_case.assertEqual(response.status_code, http_client.NO_CONTENT)
def validate_patch(self):
self.patch_object = self._create_cli_confirmation_object("enabled")
for name, case in self.cli_confirmations_service_param_test_cases.items():
patch_data = {'value': case["value"]}
if case["expect_error"]:
self.test_case.patch(self.patch_object.uuid,
patch_data,
expect_errors=True,
error_message=case["error_message"])
else:
response = self.test_case.patch(self.patch_object.uuid, patch_data)
self.patch_object.update(patch_data)
self.test_case.validate_data(self.patch_object, response)
class ApiServiceParameterPostTestSuiteMixin(ApiServiceParameterTestCaseMixin):
def setUp(self):
@ -858,6 +938,10 @@ class ApiServiceParameterPostTestSuiteMixin(ApiServiceParameterTestCaseMixin):
response = self.post(post_object)
self.validate_data(post_object, response)
def test_cli_confirmations_post(self):
self.cli_helper = CLIConfirmationTestHelper(self)
self.cli_helper.validate_post()
class ApiServiceParameterDeleteTestSuiteMixin(ApiServiceParameterTestCaseMixin):
""" Tests deletion.
@ -884,6 +968,10 @@ class ApiServiceParameterDeleteTestSuiteMixin(ApiServiceParameterTestCaseMixin):
returned_uuids = (result.uuid for result in results)
self.assertNotIn(uuid, returned_uuids)
def test_cli_confirmations_delete(self):
self.cli_helper = CLIConfirmationTestHelper(self)
self.cli_helper.validate_delete()
class ApiServiceParameterListTestSuiteMixin(ApiServiceParameterTestCaseMixin):
""" list operations """
@ -931,6 +1019,10 @@ class ApiServiceParameterPatchTestSuiteMixin(ApiServiceParameterTestCaseMixin):
self.patch(self.patch_object.uuid, new_data, expect_errors=True,
error_message="must be an integer value")
def test_cli_confirmations_patch(self):
self.cli_helper = CLIConfirmationTestHelper(self)
self.cli_helper.validate_patch()
class PlatformIPv4ControllerApiServiceParameterDeleteTestCase(ApiServiceParameterDeleteTestSuiteMixin,
base.FunctionalTest,