Remote python program in docker

Issue #214 resolved
Mathieu Guigue created an issue

My current test setup uses docker containers to mimic a computer (like a raspberry pi) collecting data and sending these to a “master” server (also running in a docker container).
The RPi should be collecting data using python, therefore I would like to use the latest python interface.
This setup is composed with:

  • a docker container running the “main” server and logger, several ports are open to allow communications and access to the web page (ports are 1175, 8080, 8443, 41483 and exposed ports are 8443, 1175, 41483).The ODB key /Experiment/security/Disable RPC hosts check was set to yes, since the address are set dynamically every time a container is started.
  • another docker container that would mimic the device/computer collecting data from the instruments and sending them to the main server. This container also has midas installed with python interface.

This last container would run the python script based on the basic_frontend.py script.
It would have a MIDAS_SERVER_HOST environment variable corresponding to the hostname of the first docker container.

When I run the basic_client.py script in the second container, the new values appears in the ODB (I can see these thanks to the web interface) as it should be; so this tells me that the containers settings are fine and allow a proper communication channel between the containers.
However when I run the basic_frontend.py script as it is, I get the following error:

[myfe_name,ERROR] [odb.cxx:2081:db_lock_database,ERROR] invalid database handle 1, aborting...
Aborted

The log on the “master server” container says:

13:32:56.579 2020/02/16 [myfe_name,TALK] Program 'myfe_name' on host '4b27dc37352e' aborted
13:32:56.577 2020/02/16 [myfe_name,ERROR] [midas.cxx:14231:rpc_server_receive,ERROR] recv_event_server() returned -1, abort
13:32:56.575 2020/02/16 [myfe_name,ERROR] [midas.cxx:12712:recv_event_server,ERROR] recv_tcp2(header) returned -1
13:32:56.573 2020/02/16 [myfe_name,ERROR] [system.cxx:4814:recv_tcp2,ERROR] unexpected connection closure
13:32:56.559 2020/02/16 [myfe_name,INFO] Program myfe_name on host 4b27dc37352e started

Then the odb has some informations about this frontend under /Equipement/MyPeriodicEquipment, but the frontend is stopped so no data bank seems to appear.
Note that running the base_frontend.py in the first container without setting a MIDAS_SERVER_HOST variable simply works.

Similarly running the python unittest doesn’t work and produces the following error:

test_sc_1       | .........[pytest,ERROR] [midas.cxx:4869:cm_transition,ERROR] Could not start a run: cm_transition() status 110, message 'Transition START deferred by client "pytest"'
test_sc_1       | [pytest,INFO] Run #16 started
test_sc_1       | [pytest,INFO] Run #16 stopped
test_sc_1       | [pytest,ERROR] [odb.cxx:2081:db_lock_database,ERROR] invalid database handle 1, aborting...

So I am kind of confused by this error, whether this comes from my setup or from the python interface itself.
Is it possible to have remote programs/frontend running using the python interface?
Was this tested?

Maybe there are other settings to be made or a web page that can help?

Thank you very much for your help!

Comments (4)

  1. Ben Smith

    Hi Mathieu,

    This looks like the bug I fixed 2 weeks ago in 24594f3. It just affected getting ODB values from a remote connection, not any other functions. There hasn’t been a release since then, so can you try the latest develop branch please?

    If you’re already up-to-date, then can you run:

    import midas.client
    c = midas.client.MidasClient("pytest")
    c._rpc_is_remote()
    

    If it returns True/False (as appropriate) then I think your code should be working. If it still isn't then there must be a similar but separate bug.

    If it says that MidasClient has no attribute _rpc_is_remote, then the client.py you’re using isn’t the latest.

    If ctypes raises an error, then the client.py is up-to-date but the C library needs to be re-compiled (a simple “make” in the build dir should be enough).

  2. Mathieu Guigue reporter

    Hi Ben,

    Thanks for your prompt answer.

    I am using the latest develop version (commit 5373e7bb6eb0cd4708d553b6fe006e53814e3880).
    The piece of code you gave returns True when I run it in the “slave” container (mimicking the data collector), so I guess the code is fine.
    But still it seems this invalid database handle error arises when creating the MyFrontend() object, so a similar but separate bug preventing to get values from a remote connection I guess…

    Are there other tests you would like me to run?

  3. Ben Smith

    Python - fix bug #214. midas.client._odb_fix_directory_order() was using the non-RPC function db_copy_json_ls(), resulting in an abort when running on a remote connection.

    Also fix a signedness issue with signed-byte values.

    → <<cset 057b95dcaea2>>

  4. Ben Smith

    Okay, I think this should be fixed now. Sorry for not catching this issue when I put in the previous fix, and thanks for the detailed report!

  5. Log in to comment