Merge "Disable k8s leader election for scheduler and controller-manager"

This commit is contained in:
Zuul 2024-11-20 22:38:23 +00:00 committed by Gerrit Code Review
commit 78ecbf688c
2 changed files with 49 additions and 0 deletions

View File

@ -1372,6 +1372,7 @@ SERVICE_PARAM_SECTION_KUBERNETES_CONTROLLER_MANAGER = 'kube_controller_manager'
SERVICE_PARAM_SECTION_KUBERNETES_SCHEDULER = 'kube_scheduler'
SERVICE_PARAM_SECTION_KUBERNETES_KUBELET = 'kubelet'
SERVICE_PARAM_NAME_KUBERNETES_FEATURE_GATES = 'feature-gates'
SERVICE_PARAM_NAME_KUBERNETES_LEADER_ELECT = 'leader-elect'
SERVICE_PARAM_SECTION_KUBERNETES_APISERVER_VOLUMES = 'kube_apiserver_volumes'
SERVICE_PARAM_SECTION_KUBERNETES_CONTROLLER_MANAGER_VOLUMES = 'kube_controller_manager_volumes'

View File

@ -6613,6 +6613,48 @@ class ConductorManager(service.PeriodicService):
values = {'state': constants.SB_STATE_CONFIGURED, 'task': constants.SB_TASK_NONE}
self.dbapi.ceph_mon_update(mon.uuid, values)
def disable_k8s_leader_election(self, context):
"""Disables k8s leader election configuration using service config.
This method disables leader election for kube-scheduler and
kube-controller-manager by either adding new service-parameter
leader-elect=false or updating exisitng service parameter value
leader-elect=true to false
"""
try:
do_apply = False
for section in [constants.SERVICE_PARAM_SECTION_KUBERNETES_SCHEDULER,
constants.SERVICE_PARAM_SECTION_KUBERNETES_CONTROLLER_MANAGER]:
new_record = {
'service': constants.SERVICE_TYPE_KUBERNETES,
'section': section,
'name': constants.SERVICE_PARAM_NAME_KUBERNETES_LEADER_ELECT,
'value': 'false',
}
try:
service_param = self.dbapi.service_parameter_get_one(
constants.SERVICE_TYPE_KUBERNETES, section,
constants.SERVICE_PARAM_NAME_KUBERNETES_LEADER_ELECT)
if service_param.value.lower() == 'true':
self.dbapi.service_parameter_update(
service_param.uuid, new_record)
do_apply = True
except exception.NotFound:
self.dbapi.service_parameter_create(new_record)
do_apply = True
if do_apply:
self.update_service_config(context,
constants.SERVICE_TYPE_KUBERNETES,
do_apply=do_apply)
LOG.info("Leader election disabled for kube-scheduler and"
" kube-controller-manager")
except Exception as ex:
LOG.error("Error disabling k8s leader election: %s" % (ex))
raise ex
def iplatform_update_by_ihost(self, context,
ihost_uuid, imsg_dict):
"""Update node data when sysinv-agent is started after a boot.
@ -6743,6 +6785,12 @@ class ConductorManager(service.PeriodicService):
ihost.save(context)
self._clear_device_image_alarm(context)
try:
if cutils.is_aio_simplex_system(self.dbapi):
self.disable_k8s_leader_election(context)
except Exception as ex:
LOG.exception(ex)
def iconfig_update_by_ihost(self, context,
ihost_uuid, imsg_dict):
"""Update applied iconfig for an ihost with the supplied data.