feat(source/istio): speed up processing with indexers

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
ivan katliarchuk 2025-08-01 19:24:41 +01:00
parent 8c7af680c0
commit fd55f6cc33
No known key found for this signature in database
GPG Key ID: 601CDBBBB76E47BE
4 changed files with 10 additions and 8 deletions

View File

@ -191,7 +191,7 @@ func (sc *gatewaySource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, e
endpoints = append(endpoints, gwEndpoints...)
}
// TODO: sort on endpoint creation
// TODO: sort on endpoint creation (performance)
for _, ep := range endpoints {
sort.Sort(ep.Targets)
}
@ -241,6 +241,7 @@ func (sc *gatewaySource) targetsFromIngress(ctx context.Context, ingressStr stri
targets := make(endpoint.Targets, 0)
// TODO: should be informer as currently this is make an API call for each gateway (performance)
ingress, err := sc.kubeClient.NetworkingV1().Ingresses(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
log.Error(err)

View File

@ -1477,7 +1477,7 @@ func testGatewayEndpoints(t *testing.T) {
t.Run(ti.title, func(t *testing.T) {
t.Parallel()
fakeKubernetesClient := fake.NewSimpleClientset()
fakeKubernetesClient := fake.NewClientset()
for _, lb := range ti.lbServices {
service := lb.Service()
@ -1524,7 +1524,7 @@ func testGatewayEndpoints(t *testing.T) {
// gateway specific helper functions
func newTestGatewaySource(loadBalancerList []fakeIngressGatewayService, ingressList []fakeIngress) (*gatewaySource, error) {
fakeKubernetesClient := fake.NewSimpleClientset()
fakeKubernetesClient := fake.NewClientset()
fakeIstioClient := istiofake.NewSimpleClientset()
for _, lb := range loadBalancerList {

View File

@ -109,10 +109,10 @@ func NewIstioVirtualServiceSource(
istioInformerFactory.Start(ctx.Done())
// wait for the local cache to be populated.
if err := informers.WaitForCacheSync(context.Background(), informerFactory); err != nil {
if err := informers.WaitForCacheSync(ctx, informerFactory); err != nil {
return nil, err
}
if err := informers.WaitForCacheSync(context.Background(), istioInformerFactory); err != nil {
if err := informers.WaitForCacheSync(ctx, istioInformerFactory); err != nil {
return nil, err
}
@ -183,7 +183,7 @@ func (sc *virtualServiceSource) Endpoints(ctx context.Context) ([]*endpoint.Endp
endpoints = append(endpoints, gwEndpoints...)
}
// TODO: sort on endpoint creation
// TODO: sort on endpoint creation (performance)
for _, ep := range endpoints {
sort.Sort(ep.Targets)
}
@ -419,6 +419,7 @@ func (sc *virtualServiceSource) targetsFromIngress(ctx context.Context, ingressS
namespace = gateway.Namespace
}
// TODO: should be informer as currently this is making an API call for each gateway (performance)
ingress, err := sc.kubeClient.NetworkingV1().Ingresses(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
log.Error(err)

View File

@ -49,7 +49,7 @@ type VirtualServiceSuite struct {
}
func (suite *VirtualServiceSuite) SetupTest() {
fakeKubernetesClient := fake.NewSimpleClientset()
fakeKubernetesClient := fake.NewClientset()
fakeIstioClient := istiofake.NewSimpleClientset()
var err error
@ -188,7 +188,7 @@ func TestNewIstioVirtualServiceSource(t *testing.T) {
_, err := NewIstioVirtualServiceSource(
context.TODO(),
fake.NewSimpleClientset(),
fake.NewClientset(),
istiofake.NewSimpleClientset(),
"",
ti.annotationFilter,