fli-iam / shanoir-ng

Shanoir (SHAring iN vivO Imaging Resources)
GNU General Public License v3.0
22 stars 22 forks source link

Qualif: Bruker import not working #486

Closed michaelkain closed 4 years ago

michaelkain commented 4 years ago

2020-09-11 11:19:41.027 WARN 1 --- [http-nio-9909-exec-1] o.s.n.s.c.GlobalExceptionHandler : Error in the rest service. org.shanoir.ng.shared.exception.RestServiceException: {"code":422,"message":"Error while converting bruker2dicom.","details":null} at org.shanoir.ng.preclinical.bruker.BrukerApiController.uploadBrukerFile(BrukerApiController.java:125) Caused by: org.shanoir.ng.shared.exception.RestServiceException: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://qualif-preclinical-bruker2dicom:5000/bruker2dicom": Host is unreachable (Host unreachable); nested exception is java.net.NoRouteToHostException: Host is unreachable (Host unreachable) at org.shanoir.ng.preclinical.bruker.BrukerApiController.startBruker2Dicom(BrukerApiController.java:154) at org.shanoir.ng.preclinical.bruker.BrukerApiController.uploadBrukerFile(BrukerApiController.java:109) ... 112 common frames omitted Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://qualif-preclinical-bruker2dicom:5000/bruker2dicom": Host is unreachable (Host unreachable); nested exception is java.net.NoRouteToHostException: Host is unreachable (Host unreachable) Caused by: java.net.NoRouteToHostException: Host is unreachable (Host unreachable)

jcomedouteau commented 4 years ago

What is interesting is that it works on shanoir-ng-dev which is running develop too. => maybe this is due to the opening of the qualif to the open world ?

First we should check that preclinical-breuker2dicom is running well @michaelkain could you do a docker logs preclinical-bruker2dicom on the qualif to check ?

Then, I think it may be a docker configuration or a firewall pb. What do you think of it @a-ba ?

Edit: I think we already had this problem during the lockdown, and anthony solved it directly on the server

a-ba commented 4 years ago

The point is that the image is not user agnostic. In production the container is not run as root, but as an ordinary user.

There are two issues which prevent the server from starting:

  1. the script /root/run.py is readable by root only

    root@qualif-preclinical_bruker2dicom:/# ls -la /root/
    total 20
    drwx------ 1 root root 4096 Jun 12  2018 .
    drwxr-xr-x 1 root root 4096 Sep 21 19:17 ..
    -rw-r--r-- 1 root root  570 Jan 31  2010 .bashrc
    -rw-r--r-- 1 root root  148 Aug 17  2015 .profile
    -rw-rw---- 1 root root  211 May 29  2018 run.py

    -> should do a chmod a+rX /root /root/run.py (or install run.py at a better place, eg: /usr/local/bin)

  2. the debug console of werkzeug fails at startup because it attempts to call getpwuid() to generate a pin code.

    I have no name!@qualif-preclinical_bruker2dicom:/$ python3 /root/run.py 
    * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    * Restarting with stat
    * Debugger is active!
    Traceback (most recent call last):
     File "/root/run.py", line 9, in <module>
       use_debugger=True, use_reloader=True)
     ...
     File "/usr/lib/python3.5/getpass.py", line 170, in getuser
       return pwd.getpwuid(os.getuid())[0]
    KeyError: 'getpwuid(): uid not found: 500'

    -> should disable the debug console (it is a bad idea to have it enabled in production anyway) :

    --- root/run.py
    +++ root/run.py
    @@ -6,4 +6,4 @@
    
    werkzeug.run_simple(
    "0.0.0.0", 5000, dicomifier_ws.Application.instance(), 
    -    use_debugger=True, use_reloader=True)
    +    use_reloader=True)
jcomedouteau commented 4 years ago

@a-ba On develop we are normally using command: ["python3", "/opt/dicomifier.ws/run.py"] and no more /root/run.py (see doker-compose). Can you update the server to use this properly ? Do you think getpwuid() will be still a pb then ?