Skip to content

Commit

Permalink
pkg/allocator: only do DeepCopy if necessary
Browse files Browse the repository at this point in the history
We don't need to always DeepCopy Cilium Identity. We just need to
perform that operation if we are going perform writes.

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm authored and aditighag committed Oct 31, 2023
1 parent e39fcae commit df05754
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/k8s/identitybackend/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ func (c *crdBackend) AcquireReference(ctx context.Context, id idpool.ID, key all
return fmt.Errorf("identity (id:%q,key:%q) does not exist", id, key)
}
}
ci = ci.DeepCopy()

ts, ok = ci.Annotations[HeartBeatAnnotation]
if ok {
log.WithField(logfields.Identity, ci).Infof("Identity marked for deletion (at %s); attempting to unmark it", ts)
ci = ci.DeepCopy()
delete(ci.Annotations, HeartBeatAnnotation)
_, err = c.Client.CiliumV2().CiliumIdentities().Update(ctx, ci, metav1.UpdateOptions{})
if err != nil {
Expand Down

0 comments on commit df05754

Please sign in to comment.