Prevent dirty service object leaking between reconciles

This commit is contained in:
Matthew Booth 2022-04-21 20:57:48 +01:00
parent f173d01c01
commit 68ad099b7b
No known key found for this signature in database
GPG Key ID: D3685B1BA4459B87

View File

@ -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