Skip to content

Commit

Permalink
wip: copy predicate object
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Oct 2, 2023
1 parent e649d08 commit fee389a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/controllers/configuration/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ func (r *CoreV1SecretReconciler) SetLogger(l logr.Logger) {
// - the secret has label: konghq.com/ca-cert:true
// - or the secret is referred by objects we care (service, ingress, gateway, ...)
func (r *CoreV1SecretReconciler) shouldReconcileSecret(obj client.Object) bool {
err := util.PopulateTypeMeta(obj)
// TypeMeta is necessary to generate the correct key for references, but we can't use the original object
// controller-runtime's client provides the same object to both predicates and the admission webhook, and can result
// in a race condition if this uses the original
o := obj.DeepCopyObject()
err := util.PopulateTypeMeta(o)
if err != nil {
r.Log.Error(err, "could not set resource TypeMeta",
"namespace", obj.GetNamespace(), "name", obj.GetName())
}
secret, ok := obj.(*corev1.Secret)
secret, ok := o.(*corev1.Secret)
if !ok {
return false
}
Expand Down

0 comments on commit fee389a

Please sign in to comment.