data race: fix concurrent read and write of secret annotations

This bug can be reproduced using "go run -race" and by creating many
Certificates and renewing them continuously. With 5000 Certificate
objects, a data race is found in less than a minute.

Signed-off-by: Maël Valais <mael@vls.dev>
This commit is contained in:
Maël Valais
2021-07-20 19:50:26 +02:00
parent c92c8c8f13
commit a96dc55e1e
@@ -102,6 +102,7 @@ func (s *SecretsManager) UpdateData(ctx context.Context, crt *cmapi.Certificate,
secret.OwnerReferences = []metav1.OwnerReference{*metav1.NewControllerRef(crt, certificateGvk)}
}
secret = secret.DeepCopy()
err = s.setValues(crt, secret, data)
if err != nil {
return err