Skip to content

Commit ed3c3cc

Browse files
committed
fix: OCPBUGS-62496 delete old profile during replacement
When a PerformanceProfile is being replaced for a NodePool, hypershift controller lack the logic to delete the old profile from the HCP namespace. This commit resolve this gap. A dedicated e2e test coverage was added on NTO repo: openshift/cluster-node-tuning-operator#1413 Signed-off-by: Talor Itzhak <[email protected]>
1 parent e7286c1 commit ed3c3cc

File tree

1 file changed

+17
-0
lines changed
  • hypershift-operator/controllers/nodepool

1 file changed

+17
-0
lines changed

hypershift-operator/controllers/nodepool/nto.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,24 @@ func (r *NodePoolReconciler) ntoReconcile(ctx context.Context, nodePool *hyperv1
523523
return err
524524
}
525525
} else {
526+
existingPerformanceProfileConfigMapList := &corev1.ConfigMapList{}
527+
if err := r.List(ctx, existingPerformanceProfileConfigMapList, &client.ListOptions{
528+
Namespace: controlPlaneNamespace,
529+
LabelSelector: labels.SelectorFromValidatedSet(labels.Set{
530+
PerformanceProfileConfigMapLabel: "true",
531+
hyperv1.NodePoolLabel: nodePool.Name}),
532+
}); err != nil && !apierrors.IsNotFound(err) {
533+
return err
534+
}
526535
performanceProfileConfigMap := PerformanceProfileConfigMap(controlPlaneNamespace, performanceProfileConfigMapName, nodePool.Name)
536+
for i := range existingPerformanceProfileConfigMapList.Items {
537+
ppConfigMap := &existingPerformanceProfileConfigMapList.Items[i]
538+
if ppConfigMap.Name != performanceProfileConfigMap.Name {
539+
if _, err := supportutil.DeleteIfNeeded(ctx, r.Client, ppConfigMap); err != nil {
540+
return fmt.Errorf("failed to delete performanceProfile ConfigMap: %w", err)
541+
}
542+
}
543+
}
527544
result, err := r.CreateOrUpdate(ctx, r.Client, performanceProfileConfigMap, func() error {
528545
return reconcilePerformanceProfileConfigMap(performanceProfileConfigMap, nodePool, performanceProfileConfig)
529546
})

0 commit comments

Comments
 (0)