From 1265a4f57dd36f287798896d52f92198a1d586dd Mon Sep 17 00:00:00 2001 From: Enxebre Date: Mon, 8 Feb 2021 12:13:48 +0100 Subject: [PATCH] Fetch nodePool by clusterName When deleting a hostedCluster we want to garbage collect all nodePools referencing that cluster --- .../controllers/hostedcluster/hostedcluster_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go b/hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go index d5ba5e4bcb21..1d196e3de246 100644 --- a/hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go +++ b/hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go @@ -313,7 +313,7 @@ func (r *HostedClusterReconciler) listNodePools(clusterNamespace, clusterName st // TODO: do a label association or something filtered := []hyperv1.NodePool{} for i, nodePool := range nodePoolList.Items { - if nodePool.Namespace == clusterNamespace && nodePool.Name == clusterName { + if nodePool.Namespace == clusterNamespace && nodePool.Spec.ClusterName == clusterName { filtered = append(filtered, nodePoolList.Items[i]) } } @@ -330,7 +330,7 @@ func (r *HostedClusterReconciler) delete(ctx context.Context, req ctrl.Request) for key := range nodePools { if err := r.Delete(ctx, &nodePools[key]); err != nil && !apierrors.IsNotFound(err) { - return fmt.Errorf("failed to delete defaultNodePool: %w", err) + return fmt.Errorf("failed to delete nodePool %q for cluster %q: %w", nodePools[key].GetName(), req.Name, err) } }