-
Notifications
You must be signed in to change notification settings - Fork 103
Only try and set permissions if permissions have changed. #295
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
Conversation
lib/filewatch/sincedb_collection.rb
Outdated
@serializer.serialize(@sincedb, io, time.to_f) | ||
end | ||
rescue => e | ||
logger.warn("sincedb_write: unable to write atomically, falling back to non-atomic write: #{path} error:", :exception => e.class, :message => e.message) |
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.
do you foresee atomic write potentially recovering, later?
if not maybe we would want the switch permanently to non-atomic ... (on the caller end).
guess this is rare, still seems like we would produce a lot of the same warn-ings (which might be fine 🤔).
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.
It's a good question. I think it might make sense to make the change 'sticky' in the event of permission errors, which are probably unlikely to recover later, and leave as is in the event of other errors.
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.
LGTM, intermittent 🔴 CI taken care of on master
This is a workaround for jruby/jruby#6693 - stat is currently reporting incorrect values of `uid` and `gid` on aarch64 linux nodes, and appears to be setting `uid` and `gid` to 0, ie `root` It is highly unlikely that `chown` needs to be called on the file - and even more unlikely that `chown` would succeed anyway - `chmod` typically requires superuser privileges, unless the change of ownerhip is a change of group to another group the user is already a member of. This workaround updates the code to only attempt to call `chown` in the unlikely event that file ownership of the temp file is different from the original file, which should avoid the scenario that is currently occurring due to the above jruby bug. This commit also falls back to a non-atomic write in the event of a failure to write the file atomically.
…errors if `atomic_write` fails due to permission errors, update the write method to be `:non_atomic_write` to avoid unnecessary warn logs every time this occurs. This commit also adds trace logging to the `atomic_write` and `non_atomic_write`.
This is a workaround for jruby/jruby#6693 - stat
is currently reporting incorrect values of
uid
andgid
on aarch64 linuxnodes, and appears to be setting
uid
andgid
to 0, ieroot
This workaround will only attempt to call
chown
if the unlikely event that thepermissions have changed. This will also "fallback" to a non-atomic write in the event
that an atomic write fails.