pub fn status_changed<T: PartialEq>(
current_value: &Option<T>,
new_value: &Option<T>,
) -> boolExpand description
Check if a status value has actually changed compared to the current status.
This helper prevents unnecessary status updates that would trigger reconciliation loops.
It compares a new status value with the existing status and returns true only if
they differ, indicating an update is needed.
§Arguments
current_value- The current status value (from existing resource)new_value- The new status value to potentially set
§Returns
true- Status has changed and needs updatingfalse- Status is unchanged, skip the update
§Example
ⓘ
use bindy::reconcilers::status_changed;
let current_ready = instance.status.as_ref()
.and_then(|s| s.ready_replicas);
let new_ready = Some(3);
if status_changed(¤t_ready, &new_ready) {
// Status has changed, safe to update
update_status(client, instance, new_ready).await?;
}§Why This Matters
In kube-rs, status updates trigger “object updated” events which cause new reconciliations. Without this check, updating status on every reconciliation creates a tight loop:
- Reconcile → Update status
- Status update → “object updated” event
- Event → New reconciliation
- Repeat from step 1 (infinite loop)
By only updating when status actually changes, we break this cycle.