Locking Mechanism#335
Merged
Merged
Conversation
cb8bc7d to
8f3f686
Compare
jenstopp
requested changes
May 27, 2026
jenstopp
left a comment
Member
There was a problem hiding this comment.
I left a couple of comments. However, only two or three of them I'd like to see addressed before merging.
The rest can be part of refactoring. I'll mark the relevant ones.
8f3f686 to
7dbf101
Compare
Contributor
Author
|
Some testing output of the mechanism |
7dbf101 to
6e45232
Compare
Add an in-memory Locker tracking two independent slots per device: an explicit slot (Lock/ClearLock, requires a positive expiry) and an auto slot (AutoLock/ClearAutoLock, command-scoped, no expiry). ClearLock and ClearAutoLock share the same signature and error contract so callers can reason about them as one pattern. ForceClearLock wipes both slots as an admin escape hatch. Lock rejects non-positive durations with ErrInvalidDuration. Add the shared OwnerHeader const used to carry owner identity over HTTP. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
The "lock" and "unlock" command names are now reserved for the per-device locking RPCs. decodeCmds rejects them with a new ErrReservedCommand sentinel. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add Lock/Unlock to the DeviceService proto and implement them on the dutagent: Lock acquires or extends a per-device lock, Unlock releases it (with a force option that releases regardless of owner). Owner identity is read from the OwnerHeader. Non-positive lock durations are rejected with InvalidArgument. dutserver embeds the Unimplemented handler since it does not forward these RPCs. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add three FSM states for per-device locking on Run: checkDeviceAccess rejects Runs by non-owners with FailedPrecondition; acquireAutoLock takes a command-scoped auto-lock; releaseAutoLock clears it once the command finishes. The Run RPC handler also delegates to releaseAutoLock as a safety net so auto-locks are not leaked on FSM error paths. dutserver forwards the owner header to the upstream agent. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
ListResponse now carries structured DeviceInfo with per-device lock state instead of bare device names. The dutctl client renders locked devices with a "[locked by ...]" annotation and adds a lock-result output type for the upcoming lock/unlock commands. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add "dutctl <device> lock [duration]" and "dutctl <device> unlock [--force]" subcommands, plus a -u flag to set the lock owner identity (defaults to user@host). The owner is sent on Run, Lock and Unlock via the OwnerHeader. Lock duration defaults to 30m and must be positive. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
6e45232 to
839d541
Compare
jenstopp
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #319