Repository navigation
K5: don't offer taking over a run lease the operator holds - #674
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
| .filter(|lease| lease.holds_at(now)); | ||
| let lease_is_yours = lease | ||
| .as_ref() | ||
| .is_some_and(|lease| !lease.holds_for_another(Some(login), now)); |
There was a problem hiding this comment.
[Design & Architecture] suggestion
lease_is_yours is computed as !lease.holds_for_another(Some(login), now), but holds_for_another is false not only when the lease is the caller's own — it is also false when the lease has no holder at all (held_by is NULL, which the column permits and AnsibleLease::held_by_another's unwrap_or("an operator") fallback anticipates). For such a lease the field reports true, contradicting the field's own doc comment ("Whether that lease is the caller's own"), and the UI hides "Take over" while showing "An operator is running …" for a lease nobody holds — previously that lease offered a take-over, which is the only way to claim it. All current writers pass Some(login) so this needs legacy or hand-edited rows to bite, but the fix is cheap and removes the double negative at the same time: express the predicate positively (e.g. lease.held_by.as_deref() == Some(login), or a holds_for(login) helper beside holds_for_another) so the field means exactly what its documentation says.
|
🦸 Review Hero Summary (round 1) · reviewed Local fix prompt (copy to your coding agent) |
🦸 Review Hero