UpdateState updates a resource's state. It can only be called from within the resource's reconciler. NOTE: Calls to UpdateState succeed even if ctx is cancelled. This enables cancelled reconcilers to update state before finishing.
(ctx context.Context, name *runtimev1.ResourceName, r *runtimev1.Resource)
| 647 | // It can only be called from within the resource's reconciler. |
| 648 | // NOTE: Calls to UpdateState succeed even if ctx is cancelled. This enables cancelled reconcilers to update state before finishing. |
| 649 | func (c *Controller) UpdateState(ctx context.Context, name *runtimev1.ResourceName, r *runtimev1.Resource) error { |
| 650 | if err := c.checkRunning(); err != nil { |
| 651 | return err |
| 652 | } |
| 653 | // Must not check ctx.Err(). See NOTE above. |
| 654 | c.lock(ctx, false) |
| 655 | defer c.unlock(ctx, false) |
| 656 | |
| 657 | if !c.isReconcilerForResource(ctx, name) { |
| 658 | return fmt.Errorf("can't update resource state from outside of reconciler") |
| 659 | } |
| 660 | |
| 661 | err := c.catalog.updateState(name, r) |
| 662 | if err != nil { |
| 663 | return err |
| 664 | } |
| 665 | |
| 666 | return nil |
| 667 | } |
| 668 | |
| 669 | // UpdateErrorAndWarning updates a resource's error and warnings. |
| 670 | // Unlike UpdateMeta and UpdateSpec, it does not cancel or enqueue reconciliation for the resource. |
no test coverage detected