Skip to content

Coordinator/place keepalive#1884

Open
asher-pem-arm wants to merge 1 commit into
labgrid-project:masterfrom
ARM-software:coordinator/place-keepalive
Open

Coordinator/place keepalive#1884
asher-pem-arm wants to merge 1 commit into
labgrid-project:masterfrom
ARM-software:coordinator/place-keepalive

Conversation

@asher-pem-arm

Copy link
Copy Markdown

Background:

Labgrid currently supports place acquisition, but acquired places remain locked until they are released explicitly.
In practice, this can lead to stale locks, where a place stays occupied even after the user is no longer actively using it.

This reduces availability of shared lab resources and often requires manual intervention to recover locked places.

What problem this solves

This MR introduces lease-based place locking, allowing places to be acquired for a limited time and released automatically if the lease is not extended.

This prevents stale locks and keeps place usage self-cleaning, while also integrating naturally with the existing reservation and scheduler semantics.

Overview:

This change adds a new lease acquisition mode alongside the existing acquire mode:

  • Acquire — default behaviour, locks a place indefinitely
  • Lease — time-limited lock, requires an active reservation and must
    be extended explicitly

Leased places are released automatically when the associated reservation expires, is cancelled, or when lease extension fails.

Lease timing and limits

Lease timing is not user-configurable via CLI. Instead, it is governed by coordinator configuration:

  • initial lease time is assigned automatically on lease
  • each extend increases the lease by a fixed amount
  • total lease time is capped by a maximum duration

This design ensures consistent behavior across users and prevents misuse or overly long locks.

Lease extension failure behavior

If extending a lease fails (for example due to exporter/resource errors),
the coordinator will cancel the lease and release the place.

This avoids leaving the system in a partially extended or inconsistent state,
especially when a place consists of multiple resources.

From the user perspective, a failed extend means the lease is no longer valid
and the place must be leased again.

CLI examples

Create a reservation:

labgrid-client reserve board=imx8 # the LG_TOKEN will be printed upon success

Lease a place using the dedicated lease command:

labgrid-client -p +<LG_TOKEN> lease

Extend the reservation to keep the lease alive:

labgrid-client extend <LG_TOKEN> --keepalive # automatically renews lease until failure or max duration

Acquire a place indefinitely (unchanged behaviour):

labgrid-client -p board-01 lock

or

labgrid-client -p board-01 acquire

@Emantor

Emantor commented Jun 9, 2026

Copy link
Copy Markdown
Member

Commit 8a098cc should be dropped, it's a function rename now while the functionality was already merged in #1872.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 4.70588% with 324 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.1%. Comparing base (915b591) to head (e65832f).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
labgrid/remote/coordinator.py 0.0% 189 Missing ⚠️
labgrid/remote/client.py 7.4% 100 Missing ⚠️
labgrid/remote/exporter.py 0.0% 26 Missing ⚠️
labgrid/remote/common.py 47.0% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1884     +/-   ##
========================================
- Coverage    46.0%   45.1%   -0.9%     
========================================
  Files         180     180             
  Lines       14464   14764    +300     
========================================
+ Hits         6654    6667     +13     
- Misses       7810    8097    +287     
Flag Coverage Δ
3.10 45.1% <4.7%> (-0.9%) ⬇️
3.11 45.1% <4.7%> (-0.9%) ⬇️
3.12 45.1% <4.7%> (-0.9%) ⬇️
3.13 45.1% <4.7%> (-0.9%) ⬇️
3.14 45.1% <4.7%> (-0.9%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Place acquisition is currently indefinite, which can lead to stale
locks when users stop interacting with a place without releasing it.

Add a lease-based locking mode that allows places to be acquired for a
limited time and expire automatically unless extended. Leases are tied
to the lifetime of a reservation.

This prevents stale locks and reduces the need for manual cleanup.

Signed-off-by: Asher Pemberton <asher.pemberton@arm.com>
Reviewed-by: Asher Pemberton <asher.pemberton@arm.com> # gatekeeper
Co-authored-by: Idan Saadon <idan.saadon@arm.com>
@asher-pem-arm asher-pem-arm force-pushed the coordinator/place-keepalive branch from e65832f to 34865ac Compare June 9, 2026 15:25
@asher-pem-arm

Copy link
Copy Markdown
Author

@Emantor updated to drop other commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants