Skip to content

Commit

Permalink
fix context for kubeconfig secret deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
m00g3n committed Nov 20, 2023
1 parent 5b0bbac commit 5875924
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/controller/gardener_cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (controller *GardenerClusterController) Reconcile(ctx context.Context, req
err := controller.Get(ctx, req.NamespacedName, &cluster)
if err != nil {
if k8serrors.IsNotFound(err) {
err = controller.deleteKubeconfigSecret(req.Name)
err = controller.deleteKubeconfigSecret(ctx, req.Name)
}

if err == nil {
Expand Down Expand Up @@ -151,13 +151,13 @@ func (controller *GardenerClusterController) persistStatusChange(ctx context.Con
return err
}

func (controller *GardenerClusterController) deleteKubeconfigSecret(clusterCRName string) error {
func (controller *GardenerClusterController) deleteKubeconfigSecret(ctx context.Context, clusterCRName string) error {
selector := client.MatchingLabels(map[string]string{
clusterCRNameLabel: clusterCRName,
})

var secretList corev1.SecretList
err := controller.Client.List(context.TODO(), &secretList, selector)
err := controller.Client.List(ctx, &secretList, selector)
if err != nil {
return err
}
Expand All @@ -166,7 +166,7 @@ func (controller *GardenerClusterController) deleteKubeconfigSecret(clusterCRNam
return errors.Errorf("unexpected numer of secrets found for cluster CR `%s`", clusterCRName)
}

return controller.Client.Delete(context.TODO(), &secretList.Items[0])
return controller.Client.Delete(ctx, &secretList.Items[0])
}

func (controller *GardenerClusterController) getSecret(shootName string) (*corev1.Secret, error) {
Expand Down

0 comments on commit 5875924

Please sign in to comment.