Adding human-readable durations to Testflinger reservation timeouts
A server-side change for Testflinger that lets reservation jobs use durations like 2h30m instead of forcing operators to convert hours into seconds.
Testflinger is the broker that sits between CI and a hardware lab. You hand it a job and it runs that job on a real physical machine in the lab. Reservation jobs hold a machine for a fixed amount of time, and until #772 (merged today), that time had to be an integer number of seconds. This post is the technical write-up. Closes #121
What was wrong before
The reservation YAML looked like this:
job_queue: myqueue
reserve_data:
ssh_keys:
- "lp:user"
timeout: 9000
If you wanted two and a half hours you did the arithmetic in your head. 9000 is the value you actually wrote.
What the change does
With #772 landed you can write the same reservation as:
timeout: 2h30m
Supported units are s/sec, m/min, h/hour, d/day, and combinations like 1d5h30m. Plain integers still work — the schema accepts both, the parser sits in testflinger-common, and the server’s DurationField returns a clean 422 Invalid duration format for anything else.
Why the parser is on the server
The change is server-only on purpose. The CLI lives in a sibling directory and adding a runtime dependency there ran into snapcraft’s cross-directory packaging rules at the time I was working on this, so the parser is on the server side and the YAML you write is normalised on the way in.
Important Links
- The PR:
#772(merged 25 Aug 2025). - Closes:
#121. - Repo:
canonical/testflinger· docs.