From 4977e993153e474392156da02d98e5725b8a29f1 Mon Sep 17 00:00:00 2001 From: albailey Date: Mon, 20 Sep 2021 07:38:08 -0500 Subject: [PATCH] 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 Change-Id: Ib1163181b19e1032fec83755102d8d556f5b1d06 --- nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py | 1 + .../nfv_vim/nfvi/objects/v1/_kube_upgrade.py | 17 +++++++++++++++++ nfv/nfv-vim/nfv_vim/strategy/_strategy.py | 11 ++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py index 3a38b918..f0dd696d 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py @@ -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 diff --git a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py index b7d03763..d8f10b9d 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py @@ -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): """ diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py index ec37e00e..f659bd65 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py @@ -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