bihealth / sodar-server

SODAR: System for Omics Data Access and Retrieval
https://github.com/bihealth/sodar-server
MIT License
14 stars 3 forks source link

Upgrade to python-irodsclient v2.1.0 #2007

Closed mikkonie closed 1 month ago

mikkonie commented 2 months ago

Now that we've switched to iRODS 4.3 in CI (#1815), it would be a good time to upgrade the python-irodsclient to the most up-to-date version.

This will be a breaking change but that's OK, as we do not intend to support iRODS 4.2 in this release anyway.

It must be noted that the last time I attempted upgrading to v2.x, we encountered problems only visible in production, not caught by CI or seen in the dev environment. Hence, thorough testing in staging must follow this update before we even dream of deploying in production.

See also #1955 and #1959.

mikkonie commented 2 months ago

It seems there have been some breaking changes in user group handling in the v2.1 release:

ERROR: test_get_objects (irodsbackend.tests.test_api_taskflow.TestIrodsBackendAPITaskflow.test_get_objects)
Test get_objects() with files in a sample collection
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mikkopen/code/sodar/taskflowbackend/tests/base.py", line 289, in tearDown
    self.clear_irods_test_data()
  File "/home/mikkopen/code/sodar/taskflowbackend/tests/base.py", line 229, in clear_irods_test_data
    irods.user_groups.remove(user_name=g[UserGroup.name])
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/manager/user_manager.py", line 105, in remove
    response = conn.recv()
               ^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/connection.py", line 152, in recv
    raise get_exception_by_code(msg.int_info, err_msg)
irods.exception.CAT_INVALID_GROUP: None

Fortunately this is Monday Mikko's problem.

mikkonie commented 1 month ago

Monday Mikko here, user group removal now fixed. Next up: something seems to go terribly wrong in make_irods_object().

======================================================================
ERROR: test_calculate (taskflowbackend.tests.test_tasks.TestBatchCalculateChecksumTask.test_calculate)
Test calculating checksum for a data object
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/pool.py", line 70, in get_connection
    conn = self.idle.pop()
           ^^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/connection.py", line 243, in _connect
    s = socket.create_connection(address, timeout)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 839, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 974, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mikkopen/code/sodar/taskflowbackend/tests/test_tasks.py", line 2176, in test_calculate
    obj = self.make_irods_object(
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/code/sodar/taskflowbackend/tests/base.py", line 98, in make_irods_object
    return make_object(self.irods, obj_path, content, **obj_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/test/helpers.py", line 205, in make_object
    with session.data_objects.open(path, 'w', **options) as obj_desc:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/manager/data_object_manager.py", line 506, in open
    conn = directed_sess.pool.get_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/pool.py", line 17, in method_
    ret = method(self,*s,**kw)
          ^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/pool.py", line 87, in get_connection
    conn = Connection(self, self.account)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/connection.py", line 62, in __init__
    self._server_version = self._connect()
                           ^^^^^^^^^^^^^^^
  File "/home/mikkopen/.virtualenvs/sodar1.0/lib/python3.11/site-packages/irods/connection.py", line 246, in _connect
    raise NetworkException(
irods.exception.NetworkException: Could not connect to specified host and port: irods-test:4488
mikkonie commented 1 month ago

This issue is due to a redirect bug (feature?) in python-irodsclient>1.1.8, where calling open() redirects the connection from localhost into the hostname set in the iRODS server.

I'm in contact with iRODS support to see what the proper solution would me. For now, adding 127.0.0.1 irods-test to /etc/hosts is the workaround.

mikkonie commented 1 month ago

The question is: how to implement a workaround for this in CI? I (foolishly) tried setting the hosts file but then realized the redirect doesn't go to "irods" in CI but a container ID:

 irods.exception.NetworkException: Could not connect to specified host and port: 38836c454cd7:4488
mikkonie commented 1 month ago

Done. I have reached iRODS support to ask whether this forced redirecting is expected behaviour or not. If not, I'll add a separate ticket to remove the workarounds and related documentation once this has been fixed.