fail2ban fails to start on 22.04 (cannot import name 'MutableMapping' from 'collections' py3.10)

Bug #1958505 reported by Lenin
38
This bug affects 6 people
Affects Status Importance Assigned to Milestone
fail2ban (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

# systemctl status fail2ban
× fail2ban.service - Fail2Ban Service
     Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-01-20 09:29:39 CET; 4min 12s ago
       Docs: man:fail2ban(1)
    Process: 3211464 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255/EXCEPTION)
   Main PID: 3211464 (code=exited, status=255/EXCEPTION)
        CPU: 174ms

Jan 20 09:29:39 wald3 systemd[1]: Started Fail2Ban Service.
Jan 20 09:29:39 wald3 fail2ban-server[3211464]: ERROR: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
Jan 20 09:29:39 wald3 systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Jan 20 09:29:39 wald3 systemd[1]: fail2ban.service: Failed with result 'exit-code'.

This is not a problem on Debian sid.

Tags: jammy
Lenin (gagarin)
description: updated
Revision history for this message
Lenin (gagarin) wrote :

hotfix: `cd /usr/bin;ln -sf python3.9 /usr/bin/python3`

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in fail2ban (Ubuntu):
status: New → Confirmed
Revision history for this message
Aaron Howell (aaron-kitten) wrote :

Simple fix here, which will need to be applied until a new version of Fail2ban with the fix included is released.
https://github.com/fail2ban/fail2ban/commit/294ec73f629d0e29cece3a1eb5dd60b6fccea41f

Revision history for this message
Robert Dinse (nanook) wrote :

Applying the fix in github resulted in a different error:

ail2ban.service - Fail2Ban Service
     Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-03-10 14:51:00 PST; 5s ago
       Docs: man:fail2ban(1)
    Process: 22282 ExecStartPre=/bin/mkdir -p /run/fail2ban (code=exited, status=0/SUCCESS)
    Process: 22283 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255/EXCEPTION)
   Main PID: 22283 (code=exited, status=255/EXCEPTION)
        CPU: 33ms

Mar 10 14:51:00 nanook systemd[1]: Starting Fail2Ban Service...
Mar 10 14:51:00 nanook systemd[1]: Started Fail2Ban Service.
Mar 10 14:51:00 nanook fail2ban-server[22283]: ERROR: No module named 'ConfigParser'
Mar 10 14:51:00 nanook systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 10 14:51:00 nanook systemd[1]: fail2ban.service: Failed with result 'exit-code'.

summary: - fail2ban fails to start on 22.04
+ fail2ban fails to start on 22.04 (cannot import name 'MutableMapping'
+ from 'collections' py3.10)
tags: added: jammy
Revision history for this message
Robert Dinse (nanook) wrote :

That did make it work but linking to a previous version of python rather than fixing the application so that it does not use a deprecated function does not seem like a good long term solution.

Revision history for this message
Lenin (gagarin) wrote :

@robert i wasnt claiming long term fix, just a hot fix for people that want fail2ban to just freaking work while having public ip and sshd running 24/7. thank you for telling me what i already knew perfectly well, waiting for the final fix for what the vendor is shipping

Revision history for this message
Robert Dinse (nanook) wrote :

Ok, hopefully a real fix by the time 22.04 becomes official. I upgraded workstation early just to find these kind of problems ahead of upgrading servers. Thank you.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package fail2ban - 0.11.2-6

---------------
fail2ban (0.11.2-6) unstable; urgency=medium

  * Cherry-pick upstream fix to fix a startup issue with Python 3.10
    (LP: #1958505)
  * Cherry-pick upstream fix for courier-auth (Closes: #1004466)
  * ignore false positive
    fail2ban: read-in-maintainer-script [postinst:41

 -- Sylvestre Ledru <email address hidden> Thu, 10 Mar 2022 22:52:59 +0100

Changed in fail2ban (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Alex (alepot-org23) wrote :

I can confirm that fail2ban now works as expected.

service fail2ban status
● fail2ban.service - Fail2Ban Service
     Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-03-22 16:07:45 GMT; 6s ago
       Docs: man:fail2ban(1)
   Main PID: 64422 (fail2ban-server)
      Tasks: 27 (limit: 38025)
     Memory: 16.4M
        CPU: 3.890s
     CGroup: /system.slice/fail2ban.service
             └─64422 /usr/bin/python3 /usr/bin/fail2ban-server -xf start

Mar 22 16:07:45 nova systemd[1]: Started Fail2Ban Service.
Mar 22 16:07:46 nova fail2ban-server[64422]: Server ready
root@nova:/usr/bin# ll python3
lrwxrwxrwx 1 root root 10 Mar 22 16:07 python3 -> python3.10*

Revision history for this message
Robert Dinse (nanook) wrote :

Confirmed, it works for me with python3.10 now as well. Thank you!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.