Support for new state for kube host upgrade kubelet

The kubernetes upgrade procedure in sysinv has changed,
and as part of the implementation changes, a new
upgraded-kubelet' state for the hosts structure was added.

The VIM code has been updated to support that new state.

Partial-Bug: 1943690
Depends-On: https://review.opendev.org/c/starlingx/config/+/809158
Signed-off-by: albailey <Al.Bailey@windriver.com>
Change-Id: Ib1163181b19e1032fec83755102d8d556f5b1d06
This commit is contained in:
albailey 2021-09-20 07:38:08 -05:00
parent 746f6d70f3
commit 4977e99315
3 changed files with 26 additions and 3 deletions

View File

@ -51,6 +51,7 @@ from nfv_vim.nfvi.objects.v1._instance_type import InstanceTypeAttributes # noq
from nfv_vim.nfvi.objects.v1._kube_rootca_update import KUBE_ROOTCA_UPDATE_STATE # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_rootca_update import KubeRootcaHostUpdate # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_rootca_update import KubeRootcaUpdate # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_upgrade import KUBE_HOST_UPGRADE_STATE # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_upgrade import KUBE_UPGRADE_STATE # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_upgrade import KubeHostUpgrade # noqa: F401
from nfv_vim.nfvi.objects.v1._kube_upgrade import KubeUpgrade # noqa: F401

View File

@ -12,6 +12,23 @@ from nfv_common.helpers import Singleton
from nfv_vim.nfvi.objects.v1._object import ObjectData
@six.add_metaclass(Singleton)
class KubeHostUpgradeState(Constants):
"""
Kube Host Upgrade State Constants
These values are copied from sysinv/common/kubernetes.py
"""
KUBE_HOST_UPGRADING_CONTROL_PLANE = Constant('upgrading-control-plane')
KUBE_HOST_UPGRADING_CONTROL_PLANE_FAILED = Constant('upgrading-control-plane-failed')
KUBE_HOST_UPGRADING_KUBELET = Constant('upgrading-kubelet')
KUBE_HOST_UPGRADING_KUBELET_FAILED = Constant('upgrading-kubelet-failed')
KUBE_HOST_UPGRADED_KUBELET = Constant('upgraded-kubelet')
# Kube Host Upgrade Constant Instantiation
KUBE_HOST_UPGRADE_STATE = KubeHostUpgradeState()
@six.add_metaclass(Singleton)
class KubeUpgradeState(Constants):
"""

View File

@ -3042,11 +3042,16 @@ class KubeUpgradeStrategy(SwUpdateStrategy,
since that means the kubelet may not be running the version
indicated. ie: upgrading-kubelet-failed
"""
from nfv_vim import nfvi
kubelet_map = dict()
for host in self.nfvi_kube_host_upgrade_list:
# if host status is anything but None, it means the kubelet may
# not yet be fully upgraded to the version indicated.
if host.status is None:
# host status can be None if the activity has not been started,
# or has been completed, in both cases the host version is correct.
# for the other three states (upgrading, upgraded, failed) only
# the upgraded state indicates the accurate kubelet version
if host.status is None \
or host.status == nfvi.objects.v1.KUBE_HOST_UPGRADE_STATE.KUBE_HOST_UPGRADED_KUBELET:
kubelet_map[host.host_uuid] = host.kubelet_version
return kubelet_map