@@ -92,10 +92,10 @@ func (r *PowerPodReconciler) Reconcile(c context.Context, req ctrl.Request) (ctr
9292 if ! pod .ObjectMeta .DeletionTimestamp .IsZero () || pod .Status .Phase == corev1 .PodSucceeded {
9393 // If the pod's deletion timestamp is not zero, then the pod has been deleted
9494
95- powerPodState := r .State .GetPodFromState ( pod . GetName (), pod .GetNamespace ( ))
95+ powerPodState := r .State .GetPodFromStateUID ( string ( pod .GetUID () ))
9696
97- logger .V (5 ).Info ("removing the pod from the internal state" )
98- if err = r .State .DeletePodFromState ( pod . GetName (), pod .GetNamespace ( )); err != nil {
97+ logger .V (5 ).Info ("Removing Pod from internal state" , "Pod Name" , pod . GetName (), "UID" , pod . GetUID () )
98+ if err = r .State .DeletePodFromStateUID ( string ( pod .GetUID () )); err != nil {
9999 logger .Error (err , "error removing the pod from the internal state" )
100100 return ctrl.Result {}, err
101101 }
@@ -105,14 +105,15 @@ func (r *PowerPodReconciler) Reconcile(c context.Context, req ctrl.Request) (ctr
105105 for _ , container := range powerPodState .Containers {
106106 workload := container .Workload
107107 cpus := container .ExclusiveCPUs
108+ logger .V (5 ).Info ("Removing" , "Workload" , workload , "CPUs" , cpus )
108109 if _ , exists := workloadToCPUsRemoved [workload ]; exists {
109110 workloadToCPUsRemoved [workload ] = append (workloadToCPUsRemoved [workload ], cpus ... )
110111 } else {
111112 workloadToCPUsRemoved [workload ] = cpus
112113 }
113114 }
114115 for workloadName , cpus := range workloadToCPUsRemoved {
115- logger .V (5 ).Info ("retrieving the workload instance %s " , workloadName )
116+ logger .V (5 ).Info ("retrieving the workload instance" , "Workload Name " , workloadName )
116117 workload := & powerv1.PowerWorkload {}
117118 err = r .Get (context .TODO (), client.ObjectKey {
118119 Namespace : IntelPowerNamespace ,
@@ -209,6 +210,7 @@ func (r *PowerPodReconciler) Reconcile(c context.Context, req ctrl.Request) (ctr
209210
210211 workloadContainer := container
211212 workloadContainer .Pod = pod .Name
213+ workloadContainer .Workload = workloadName
212214 containerList = append (containerList , workloadContainer )
213215 }
214216 for i , newContainer := range containerList {
@@ -280,9 +282,11 @@ func (r *PowerPodReconciler) getPowerProfileRequestsFromContainers(containers []
280282 containerID := getContainerID (pod , container .Name )
281283 coreIDs , err := r .PodResourcesClient .GetContainerCPUs (pod .GetName (), container .Name )
282284 if err != nil {
285+ logger .V (5 ).Info ("Error getting CoreIDs." , "ContainerID" , containerID )
283286 return map [string ][]uint {}, []powerv1.Container {}, err
284287 }
285288 cleanCoreList := getCleanCoreList (coreIDs )
289+ logger .V (5 ).Info ("Reserving cores to container." , "ContainerID" , containerID , "Cores" , cleanCoreList )
286290
287291 logger .V (5 ).Info ("creating the power container" )
288292 powerContainer := & powerv1.Container {}
@@ -347,7 +351,7 @@ func getNewWorkloadContainerList(nodeContainers []powerv1.Container, podStateCon
347351
348352 logger .V (5 ).Info ("checking if there are new containers for the workload" )
349353 for _ , container := range nodeContainers {
350- if ! isContainerInList (container .Name , podStateContainers , logger ) {
354+ if ! isContainerInList (container .Name , container . Id , podStateContainers , logger ) {
351355 newNodeContainers = append (newNodeContainers , container )
352356 }
353357 }
@@ -356,9 +360,9 @@ func getNewWorkloadContainerList(nodeContainers []powerv1.Container, podStateCon
356360}
357361
358362// Helper function - if container is in a list of containers
359- func isContainerInList (name string , containers []powerv1.Container , logger * logr.Logger ) bool {
363+ func isContainerInList (name string , uid string , containers []powerv1.Container , logger * logr.Logger ) bool {
360364 for _ , container := range containers {
361- if container .Name == name {
365+ if container .Name == name && container . Id == uid {
362366 return true
363367 }
364368 }
0 commit comments