-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable lock file if directory does not exist or no permissions #2190
Disable lock file if directory does not exist or no permissions #2190
Conversation
Codecov Report
Additional details and impacted files
|
Robot Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed check is not working: if a user cannot write the lock while another user could, then this user will not be able to run the agent or the mapper.
A better approach is to leverage the error returned by Flockfile::new_lock()
, ignoring the error if !error.non_exclusive_access()
The fix is a bit more involved as |
6917615
to
89cfef3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is correct and behaves as described by #2131
However, the warning message published when locks are disabled could be more useful for the user who intends to enable locks.
$ tedge config set run.path /tmp
$ target/debug/tedge-mapper --debug collectd
2023-08-28T07:34:59.955514889Z INFO flockfile::unix: The locking mechanism is not active, so it does not prevent running multiple instances of tedge-mapper-collectd.
This should tell the user why locking mechanism is not active.
The locking mechanism is not active, as `/tmp/lock` is not a directory with write access.
Might be a bit verbose though. @reubenmiller what's your point of view?
I really like the Didier's suggestion, so please use the statement.
|
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
fdcb98c
to
3987f99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Proposed changes
This PR disable lock file mechanism when
{run.path}/lock
does not exist or directory is not writable.Types of changes
Paste Link to the issue
#2131
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments