Fix unexpected behavior on reboot

when the machine reboots after the application upload and before
the "apply" command, the application doesn't install anymore.

To resolve this, the patch file was embedded in the lifecycle
file, removing the dependency on its presence in the file system.

Test Plan:
PASS: AIO-SX application upload, and install, successfully
PASS: AIO-SX application apply before a system reboot
PASS: AIO-SX application updated successfully
PASS: AIO-DX application upload, and install, successfully
PASS: AIO-DX application apply before a system reboot
PASS: AIO-DX application updated successfully
PASS: AIO-DX host swact

Closes-bug: #2084085
Change-Id: I88ba44f6d9d068fe5041fbefe3c032a34d1e393a
Signed-off-by: Eduardo Alberti <eduardo.alberti@windriver.com>
This commit is contained in:
Eduardo Alberti 2024-10-01 13:36:50 -03:00 committed by Thiago Miranda
parent 96b228fc3d
commit 5179f7628a
9 changed files with 121 additions and 117 deletions

View File

@ -1,3 +1,9 @@
python3-k8sapp-kubernetes-power-manager (1.2-1) unstable; urgency=medium
* File location changes
-- Eduardo Alberti <eduardo.alberti@windriver.com> Tue, 1 Oct 2024 12:00:00 -0300
python3-k8sapp-kubernetes-power-manager (1.2-0) unstable; urgency=medium
* Change reserved cores profile

View File

@ -1,6 +1,6 @@
---
debname: python3-k8sapp-kubernetes-power-manager
debver: 1.2-0
debver: 1.2-1
src_path: k8sapp_kubernetes_power_manager
revision:
dist: $STX_DIST

View File

@ -20,6 +20,112 @@ HELM_APP_KUBERNETES_POWER_MANAGER_CRD_TIMEOFDAYCRONJOBS = 'timeofdaycronjobs.pow
HELM_APP_KUBERNETES_POWER_MANAGER_CRD_TIMEOFDAYS = 'timeofdays.power.intel.com'
HELM_APP_KUBERNETES_POWER_MANAGER_CRD_UNCORES = 'uncores.power.intel.com'
POWERWORKLOADS_PATCH = """ # noqa: E501
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
description: PowerWorkload is the Schema for the powerworkloads API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PowerWorkloadSpec defines the desired state of PowerWorkload
properties:
allCores:
description: AllCores determines if the Workload is to be applied
to all cores (i.e. use the Default Workload)
type: boolean
name:
description: The name of the workload
type: string
powerNodeSelector:
additionalProperties:
type: string
description: The labels signifying the nodes the user wants to use
type: object
powerProfile:
description: PowerProfile is the Profile that this PowerWorkload is
based on
type: string
reservedCPUs:
description: Reserved CPUs are the CPUs that have been reserved by
Kubelet for use by the Kubernetes admin process This list must match
the list in the user's Kubelet configuration
items:
properties:
cores:
items:
type: integer
type: array
powerProfile:
type: string
required:
- cores
type: object
type: array
workloadNodes:
properties:
containers:
items:
properties:
exclusiveCpus:
description: The exclusive CPUs given to this Container
items:
type: integer
type: array
id:
description: The ID of the Container
type: string
name:
description: The name of the Container
type: string
pod:
description: The name of the Pod the Container is running
on
type: string
powerProfile:
description: The PowerProfile that the Container is utilizing
type: string
workload:
description: The PowerWorkload that the Container is utilizing
type: string
type: object
type: array
cpuIds:
items:
type: integer
type: array
name:
type: string
type: object
required:
- name
type: object
status:
description: PowerWorkloadStatus defines the observed state of PowerWorkload
properties:
'node:':
description: The Node that this Shared PowerWorkload is associated
with
type: string
type: object
type: object
served: true
storage: true
"""
HELM_APP_KUBERNETES_POWER_MANAGER_CRDS = [
HELM_APP_KUBERNETES_POWER_MANAGER_CRD_CSTATES,
HELM_APP_KUBERNETES_POWER_MANAGER_CRD_POWERCONFIGS,
@ -45,5 +151,3 @@ HELM_CHART_NFD = 'node-feature-discovery'
APPLICATION_CSTATE = "C1"
CSTATE_C0 = "POLL"
PLATFORM_CSTATE = "C6"
PATCH_FILE = "/tmp/workloadPatch.yaml"

View File

@ -252,8 +252,7 @@ class KubernetesPowerManagerAppLifecycleOperator(base.AppLifecycleOperator):
LOG.debug(f"Running app update to {app.version} version")
try:
file = open(app_constants.PATCH_FILE, "r")
body = yaml.safe_load(file.read())
body = yaml.safe_load(app_constants.POWERWORKLOADS_PATCH)
k8s_client_ext = app_op._kube._get_kubernetesclient_extensions()
k8s_client_ext.patch_custom_resource_definition(
@ -261,12 +260,6 @@ class KubernetesPowerManagerAppLifecycleOperator(base.AppLifecycleOperator):
HELM_APP_KUBERNETES_POWER_MANAGER_CRD_POWERWORKLOADS),
body=body,
)
except yaml.YAMLError:
LOG.error(f"An error occurred during {app_constants.PATCH_FILE} "
"yaml reading.")
except FileNotFoundError:
LOG.error(f"The existence of {app_constants.PATCH_FILE} "
"was expected")
except Exception as ex:
LOG.error("Failed to path PowerWorkload resource "
"during app update."

View File

@ -1,3 +1,9 @@
stx-kubernetes-power-manager (1.1-1) unstable; urgency=medium
* File location changes
-- Eduardo Alberti <eduardo.alberti@windriver.com> Tue, 1 Oct 2024 12:00:00 +0000
stx-kubernetes-power-manager (1.1-0) unstable; urgency=medium
* Renaming package according to the new app structure.

View File

@ -57,7 +57,6 @@ override_dh_auto_install:
# Install the app tar file.
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER)
install -p -D -m 755 files/workloadPatch.yaml $(ROOT)/tmp/workloadPatch.yaml
override_dh_auto_test:

View File

@ -1,2 +1 @@
usr/local/share/applications/helm/*
tmp/*

View File

@ -4,7 +4,7 @@
#
---
debname: stx-kubernetes-power-manager
debver: 1.1-0
debver: 1.1-1
src_path: stx-kubernetes-power-manager
revision:
dist: $STX_DIST

View File

@ -1,103 +0,0 @@
spec:
versions:
- name: v1
schema:
openAPIV3Schema:
description: PowerWorkload is the Schema for the powerworkloads API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PowerWorkloadSpec defines the desired state of PowerWorkload
properties:
allCores:
description: AllCores determines if the Workload is to be applied
to all cores (i.e. use the Default Workload)
type: boolean
name:
description: The name of the workload
type: string
powerNodeSelector:
additionalProperties:
type: string
description: The labels signifying the nodes the user wants to use
type: object
powerProfile:
description: PowerProfile is the Profile that this PowerWorkload is
based on
type: string
reservedCPUs:
description: Reserved CPUs are the CPUs that have been reserved by
Kubelet for use by the Kubernetes admin process This list must match
the list in the user's Kubelet configuration
items:
properties:
cores:
items:
type: integer
type: array
powerProfile:
type: string
required:
- cores
type: object
type: array
workloadNodes:
properties:
containers:
items:
properties:
exclusiveCpus:
description: The exclusive CPUs given to this Container
items:
type: integer
type: array
id:
description: The ID of the Container
type: string
name:
description: The name of the Container
type: string
pod:
description: The name of the Pod the Container is running
on
type: string
powerProfile:
description: The PowerProfile that the Container is utilizing
type: string
workload:
description: The PowerWorkload that the Container is utilizing
type: string
type: object
type: array
cpuIds:
items:
type: integer
type: array
name:
type: string
type: object
required:
- name
type: object
status:
description: PowerWorkloadStatus defines the observed state of PowerWorkload
properties:
'node:':
description: The Node that this Shared PowerWorkload is associated
with
type: string
type: object
type: object
served: true
storage: true