Skip to content

Commit a65889d

Browse files
authored
fix goroutine leaks in ambient index DelayedInformers. (#58479)
* Fix multicluster goroutine leaks Signed-off-by: Petr McAllister <[email protected]> * revert unneeded changes Signed-off-by: Petr McAllister <[email protected]> --------- Signed-off-by: Petr McAllister <[email protected]>
1 parent 4fd833c commit a65889d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pilot/pkg/serviceregistry/kube/controller/ambient/ambientindex.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,19 @@ func New(options Options) Index {
186186
)...)
187187
authzPolicies := kclient.NewDelayedInformer[*securityclient.AuthorizationPolicy](options.Client,
188188
gvr.AuthorizationPolicy, kubetypes.StandardInformer, configFilter)
189+
// Start with a.stop to ensure the informer respects the index's stop channel
190+
authzPolicies.Start(a.stop)
189191
AuthzPolicies := krt.WrapClient[*securityclient.AuthorizationPolicy](authzPolicies, opts.WithName("informer/AuthorizationPolicies")...)
190192

191193
peerAuths := kclient.NewDelayedInformer[*securityclient.PeerAuthentication](options.Client,
192194
gvr.PeerAuthentication, kubetypes.StandardInformer, configFilter)
195+
// Start with a.stop to ensure the informer respects the index's stop channel
196+
peerAuths.Start(a.stop)
193197
PeerAuths := krt.WrapClient[*securityclient.PeerAuthentication](peerAuths, opts.WithName("informer/PeerAuthentications")...)
194198

195199
gatewayClient := kclient.NewDelayedInformer[*gatewayv1.Gateway](options.Client, gvr.KubernetesGateway, kubetypes.StandardInformer, filter)
200+
// Start with a.stop to ensure the informer respects the index's stop channel
201+
gatewayClient.Start(a.stop)
196202
Gateways := krt.WrapClient[*gatewayv1.Gateway](gatewayClient, opts.With(
197203
krt.WithName("informer/Gateways"),
198204
krt.WithMetadata(krt.Metadata{
@@ -201,6 +207,8 @@ func New(options Options) Index {
201207
)...)
202208

203209
gatewayClassClient := kclient.NewDelayedInformer[*gatewayv1.GatewayClass](options.Client, gvr.GatewayClass, kubetypes.StandardInformer, filter)
210+
// Start with a.stop to ensure the informer respects the index's stop channel
211+
gatewayClassClient.Start(a.stop)
204212
GatewayClasses := krt.WrapClient[*gatewayv1.GatewayClass](gatewayClassClient, opts.WithName("informer/GatewayClasses")...)
205213
Pods := krt.NewFilteredInformer[*corev1.Pod](options.Client, kclient.Filter{
206214
ObjectFilter: options.Client.ObjectFilter(),
@@ -215,10 +223,14 @@ func New(options Options) Index {
215223

216224
serviceEntries := kclient.NewDelayedInformer[*networkingclient.ServiceEntry](options.Client,
217225
gvr.ServiceEntry, kubetypes.StandardInformer, configFilter)
226+
// Start with a.stop to ensure the informer respects the index's stop channel
227+
serviceEntries.Start(a.stop)
218228
ServiceEntries := krt.WrapClient[*networkingclient.ServiceEntry](serviceEntries, opts.WithName("informer/ServiceEntries")...)
219229

220230
workloadEntries := kclient.NewDelayedInformer[*networkingclient.WorkloadEntry](options.Client,
221231
gvr.WorkloadEntry, kubetypes.StandardInformer, configFilter)
232+
// Start with a.stop to ensure the informer respects the index's stop channel
233+
workloadEntries.Start(a.stop)
222234
WorkloadEntries := krt.WrapClient[*networkingclient.WorkloadEntry](workloadEntries, opts.WithName("informer/WorkloadEntries")...)
223235

224236
servicesClient := kclient.NewFiltered[*corev1.Service](options.Client, filter)

0 commit comments

Comments
 (0)