From 68ad099b7b734bcac6c1ed794862b16e334ed4c2 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Thu, 21 Apr 2022 20:57:48 +0100 Subject: [PATCH] Prevent dirty service object leaking between reconciles --- .../k8s.io/cloud-provider/controllers/service/controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/cloud-provider/controllers/service/controller.go b/staging/src/k8s.io/cloud-provider/controllers/service/controller.go index c57a3d9a314..a7d9c059ca9 100644 --- a/staging/src/k8s.io/cloud-provider/controllers/service/controller.go +++ b/staging/src/k8s.io/cloud-provider/controllers/service/controller.go @@ -876,7 +876,10 @@ func (s *Controller) syncService(ctx context.Context, key string) error { case err != nil: runtime.HandleError(fmt.Errorf("Unable to retrieve service %v from store: %v", key, err)) default: - err = s.processServiceCreateOrUpdate(ctx, service, key) + // It is not safe to modify an object returned from an informer. + // As reconcilers may modify the service object we need to copy + // it first. + err = s.processServiceCreateOrUpdate(ctx, service.DeepCopy(), key) } return err