func (m *pendingMembersFinalizer) findVirtualRouterMembers(ctx context.Context, ms *appmesh.Mesh) ([]*appmesh.VirtualRouter, error) {
	vrList := &appmesh.VirtualRouterList{}
	if err := m.k8sClient.List(ctx, vrList); err != nil {
		return nil, err
	}
	members := make([]*appmesh.VirtualRouter, 0, len(vrList.Items))
	for i := range vrList.Items {
		vr := &vrList.Items[i]
		if vr.Spec.MeshRef == nil || !IsMeshReferenced(ms, *vr.Spec.MeshRef) {
			continue
		}
		members = append(members, vr)
	}
	return members, nil
}
findVirtualRouterMembers find the VirtualRouter members for this mesh.
package mesh
import (
	"context"
	"fmt"
	appmesh "github.com/aws/aws-app-mesh-controller-for-k8s/apis/appmesh/v1beta2"
	"github.com/aws/aws-app-mesh-controller-for-k8s/pkg/runtime"
	"github.com/go-logr/logr"
	"github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/client-go/tools/record"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"strings"
	"time"
)
const (
	pendingMembersFinalizerEvaluateInterval = 60 * time.Second
)
type MembersFinalizer interface {
	Finalize(ctx context.Context, ms *appmesh.Mesh) error
}
func NewPendingMembersFinalizer(k8sClient client.Client, eventRecorder record.EventRecorder, log logr.Logger) MembersFinalizer {
	return &pendingMembersFinalizer{
		k8sClient:        k8sClient,
		eventRecorder:    eventRecorder,
		log:              log,
		evaluateInterval: pendingMembersFinalizerEvaluateInterval,
	}
}
type pendingMembersFinalizer struct {
	k8sClient     client.Client
	eventRecorder record.EventRecorder
	log           logr.Logger
	evaluateInterval time.Duration
}
func (m *pendingMembersFinalizer) Finalize(ctx context.Context, ms *appmesh.Mesh) error {
	vsMembers, err := m.findVirtualServiceMembers(ctx, ms)
	if err != nil {
		return err
	}
	vrMembers, err := m.findVirtualRouterMembers(ctx, ms)
	if err != nil {
		return err
	}
	vnMembers, err := m.findVirtualNodeMembers(ctx, ms)
	if err != nil {
		return err
	}
	vgMembers, err := m.findVirtualGatewayMembers(ctx, ms)
	if err != nil {
		return err
	}
	grMembers, err := m.findGatewayRouteMembers(ctx, ms)
	if err != nil {
		return err
	}
	if len(vsMembers) == 0 && len(vrMembers) == 0 && len(vnMembers) == 0 && len(vgMembers) == 0 && len(grMembers) == 0 {
		return nil
	}
	message := m.buildPendingMembersEventMessage(ctx, vsMembers, vrMembers, vnMembers, vgMembers, grMembers)
	m.eventRecorder.Eventf(ms, corev1.EventTypeWarning, "PendingMembersDeletion", message)
	return runtime.NewRequeueAfterError(errors.New("pending members deletion"), m.evaluateInterval)
}
func (m *pendingMembersFinalizer) findVirtualServiceMembers(ctx context.Context, ms *appmesh.Mesh) ([]*appmesh.VirtualService, error) {
	vsList := &appmesh.VirtualServiceList{}
	if err := m.k8sClient.List(ctx, vsList); err != nil {
		return nil, err
	}
	members := make([]*appmesh.VirtualService, 0, len(vsList.Items))
	for i := range vsList.Items {
		vs := &vsList.Items[i]
		if vs.Spec.MeshRef == nil || !IsMeshReferenced(ms, *vs.Spec.MeshRef) {
			continue
		}
		members = append(members, vs)
	}
	return members, nil
}