Skip to content
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

sr_watch crashes when encountering file it can't read #238

Closed
EricFunk opened this issue Jul 31, 2019 · 4 comments
Closed

sr_watch crashes when encountering file it can't read #238

EricFunk opened this issue Jul 31, 2019 · 4 comments
Assignees
Labels
bug Something isn't working likely-fixed likely fix is in the repository, success not confirmed yet.

Comments

@EricFunk
Copy link

If a directory is being watched with sr_watch and someone goes in and attempts to create a new file with:

vi somefile

The presence of the unreadable swap file '.somefile.swp'. causes the observer to trigger a creation event, then when sr_post.py attempts to compute a checksum. The following line:

fp = open(path,'rb')

triggers an exception, but since it isn't handled the sr_watch process completely crashes. Here is the resulting error message:

2019-07-31 13:31:32,901 [DEBUG] trim_headers
2019-07-31 13:31:32,902 [DEBUG] sum set by compute_sumstr
2019-07-31 13:31:32,902 [DEBUG] sr_config set_sumalgo d
2019-07-31 13:31:32,976 [ERROR] Traceback (most recent call last):
2019-07-31 13:31:32,977 [ERROR]   File "/usr/bin/sr_watch", line 11, in <module>
2019-07-31 13:31:32,977 [ERROR] load_entry_point('metpx-sarracenia==2.19.4b2', 'console_scripts', 'sr_watch')()
2019-07-31 13:31:32,978 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_watch.py", line 65, in main
2019-07-31 13:31:32,978 [ERROR] watch.exec_action(action,old)
2019-07-31 13:31:32,978 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_instances.py", line 301, in exec_action
2019-07-31 13:31:32,978 [ERROR] elif action == 'start'      : self.start_parent()
2019-07-31 13:31:32,979 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_instances.py", line 785, in start_parent
2019-07-31 13:31:32,979 [ERROR] self.start()
2019-07-31 13:31:32,979 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 1480, in start
2019-07-31 13:31:32,980 [ERROR] self.run()
2019-07-31 13:31:32,980 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 1467, in run
2019-07-31 13:31:32,981 [ERROR] if self.sleep > 0: self.watch_loop()
2019-07-31 13:31:32,981 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 1285, in watch_loop
2019-07-31 13:31:32,981 [ERROR] self.wakeup()
2019-07-31 13:31:32,981 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 1161, in wakeup
2019-07-31 13:31:32,982 [ERROR] done = self.process_event( event, src, dst )
2019-07-31 13:31:32,982 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 1056, in process_event
2019-07-31 13:31:32,982 [ERROR] ok = self.post1file(src,lstat)
2019-07-31 13:31:32,982 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 981, in post1file
2019-07-31 13:31:32,983 [ERROR] ok = self.post_file(path,lstat)
2019-07-31 13:31:32,983 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 541, in post_file
2019-07-31 13:31:32,983 [ERROR] sumstr = self.compute_sumstr(path, fsiz)
2019-07-31 13:31:32,983 [ERROR]   File "/usr/lib/python3/dist-packages/sarra/sr_post.py", line 622, in compute_sumstr
2019-07-31 13:31:32,984 [ERROR] fp = open(path,'rb')
2019-07-31 13:31:32,984 [ERROR] PermissionError
2019-07-31 13:31:32,984 [ERROR] :
2019-07-31 13:31:32,984 [ERROR] [Errno 13] Permission denied: '/apps/bullprep/fcsts/transmit/uplink-transmit/.test10.swp'

I imagine a reject statement can be included to ignore these types of files, but I am guessing it should perhaps cause an error message and not cause it to crash.

@benlapETS
Copy link
Contributor

benlapETS commented Aug 13, 2019

  • I agree with you this shouldnt crash. This is part of the bad coding practice that led the dev of sr_post that I am trying to fix for a while. But from my side, I added handling when file was not found but I guess I will have to expand the handling to OSError to be less specific as we learn how to handle each case properly.

  • BTW, why would we need to watch hidden files/folder ? is there some cases that we want to watch them ? I guess it wouldnt be the rule but the exception...

@benlapETS
Copy link
Contributor

I pushed the fix directly to master, give me some feedback if you see any problem.

@benlapETS benlapETS self-assigned this Aug 13, 2019
@benlapETS benlapETS added the likely-fixed likely fix is in the repository, success not confirmed yet. label Aug 13, 2019
@petersilva
Copy link
Contributor

@EricFunk ... this fix should be available in daily builds that you can get from
the daily repo:

https://launchpad.net/~ssc-hpc-chp-spc/+archive/ubuntu/metpx-daily

if there is some place you want to test it.

@petersilva petersilva added the bug Something isn't working label Sep 16, 2019
@petersilva
Copy link
Contributor

fix released in 2.19.09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working likely-fixed likely fix is in the repository, success not confirmed yet.
Projects
None yet
Development

No branches or pull requests

3 participants