Lock locks the controller's catalog and delays scheduling of new reconciliations until the lock is released. It can only be called from within a reconciler invocation. While the lock is held, resources can only be edited by a caller using the ctx passed to Lock.
(ctx context.Context)
| 814 | // It can only be called from within a reconciler invocation. |
| 815 | // While the lock is held, resources can only be edited by a caller using the ctx passed to Lock. |
| 816 | func (c *Controller) Lock(ctx context.Context) { |
| 817 | inv := invocationFromContext(ctx) |
| 818 | if inv == nil { |
| 819 | panic("Lock called outside of a reconciler invocation") |
| 820 | } |
| 821 | if inv.holdsLock { |
| 822 | panic("Lock called by invocation that already holds the lock") |
| 823 | } |
| 824 | inv.holdsLock = true |
| 825 | c.mu.Lock() |
| 826 | } |
| 827 | |
| 828 | // Unlock releases the lock acquired by Lock. |
| 829 | func (c *Controller) Unlock(ctx context.Context) { |
no test coverage detected